From: <arn...@us...> - 2008-01-19 10:18:36
|
Revision: 967 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=967&view=rev Author: arnetheduck Date: 2008-01-19 02:18:34 -0800 (Sat, 19 Jan 2008) Log Message: ----------- Translations + redone transferview (unfinished) Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/dcpp/ADLSearch.h dcplusplus/trunk/dcpp/QueueManager.cpp dcplusplus/trunk/dcpp/QueueManager.h dcplusplus/trunk/win32/ADLSProperties.cpp dcplusplus/trunk/win32/ADLSearchFrame.cpp dcplusplus/trunk/win32/AboutDlg.cpp dcplusplus/trunk/win32/CommandDlg.cpp dcplusplus/trunk/win32/DirectoryListingFrame.cpp dcplusplus/trunk/win32/FavHubProperties.cpp dcplusplus/trunk/win32/FinishedFrameBase.h dcplusplus/trunk/win32/HashProgressDlg.cpp dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/MagnetDlg.cpp dcplusplus/trunk/win32/MainWindow.cpp dcplusplus/trunk/win32/PublicHubsFrame.cpp dcplusplus/trunk/win32/QueueFrame.cpp dcplusplus/trunk/win32/SearchFrame.cpp dcplusplus/trunk/win32/SpyFrame.cpp dcplusplus/trunk/win32/TransferView.cpp dcplusplus/trunk/win32/TransferView.h dcplusplus/trunk/win32/WinUtil.cpp dcplusplus/trunk/win32/stdafx.h Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/changelog.txt 2008-01-19 10:18:34 UTC (rev 967) @@ -6,12 +6,14 @@ * [ADC] Searches filtered by token if available so that each search window only gets its own results * [ADC] Implemented test version of bloom filters which will dramatically reduce hub bandwidth usage for TTH searches * Fixed a crash with partial list browsing -* Replaced homegrown i18n solution with gettext +* Replaced homegrown i18n solution with gettext (thanks david grundberg, mikejj) * Fixed an issue with nick encodings and nmdc connections (thanks stanislav maslovski) * Added download view which shows per-file download information * Chat timestamps on by default * Added tab drag/drop (thanks poy) +* Changed Pothead to mikejj + -- 0.704 2007-12-14 -- * Hub lists added to utilize Coral's distributed network (ullner) * Use system header arrows on common controls 6+ (thanks poy) Modified: dcplusplus/trunk/dcpp/ADLSearch.h =================================================================== --- dcplusplus/trunk/dcpp/ADLSearch.h 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/dcpp/ADLSearch.h 2008-01-19 10:18:34 UTC (rev 967) @@ -110,26 +110,20 @@ } } - tstring SourceTypeToDisplayString(SourceType t) { - switch(t) { - default: - case OnlyFile: return TSTRING(FILENAME); - case OnlyDirectory: return TSTRING(DIRECTORY); - case FullPath: return TSTRING(ADLS_FULL_PATH); - } - } - // Maximum & minimum file sizes (in bytes). // Negative values means do not check. int64_t minFileSize; int64_t maxFileSize; + enum SizeType { SizeBytes = TypeFirst, SizeKibiBytes, SizeMebiBytes, SizeGibiBytes }; + SizeType typeFileSize; + SizeType StringToSizeType(const string& s) { if(Util::stricmp(s.c_str(), "B") == 0) { return SizeBytes; @@ -143,6 +137,7 @@ return SizeBytes; } } + string SizeTypeToString(SizeType t) { switch(t) { default: @@ -152,15 +147,7 @@ case SizeGibiBytes: return "GiB"; } } - tstring SizeTypeToDisplayString(SizeType t) { - switch(t) { - default: - case SizeBytes: return CTSTRING(B); - case SizeKibiBytes: return CTSTRING(KiB); - case SizeMebiBytes: return CTSTRING(MiB); - case SizeGibiBytes: return CTSTRING(GiB); - } - } + int64_t GetSizeBase() { switch(typeFileSize) { default: Modified: dcplusplus/trunk/dcpp/QueueManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/QueueManager.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/dcpp/QueueManager.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -253,6 +253,25 @@ add(qi); } +int64_t QueueManager::UserQueue::getQueued(const UserPtr& aUser) const { + int64_t total = 0; + for(size_t i = 0; i < QueueItem::LAST; ++i) { + const QueueItem::UserListMap& ulm = userQueue[i]; + QueueItem::UserListMap::const_iterator iulm = ulm.find(aUser); + if(iulm == ulm.end()) { + continue; + } + + for(QueueItem::List::const_iterator j = iulm->second.begin(); j != iulm->second.end(); ++j) { + const QueueItem::Ptr qi = *j; + if(qi->getSize() != -1) { + total += qi->getSize() - qi->getDownloadedBytes(); + } + } + } + return total; +} + QueueItem* QueueManager::UserQueue::getRunning(const UserPtr& aUser) { QueueItem::UserIter i = running.find(aUser); return (i == running.end()) ? 0 : i->second; @@ -1061,6 +1080,11 @@ } } +int64_t QueueManager::getQueued(const UserPtr& aUser) const { + Lock l(cs); + return userQueue.getQueued(aUser); +} + void QueueManager::removeSource(const UserPtr& aUser, int reason) throw() { bool isRunning = false; string removeRunning; Modified: dcplusplus/trunk/dcpp/QueueManager.h =================================================================== --- dcplusplus/trunk/dcpp/QueueManager.h 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/dcpp/QueueManager.h 2008-01-19 10:18:34 UTC (rev 967) @@ -108,6 +108,8 @@ void putDownload(Download* aDownload, bool finished) throw(); void setFile(Download* download); + int64_t getQueued(const UserPtr& aUser) const; + /** @return The highest priority download the user has, PAUSED may also mean no downloads */ QueueItem::Priority hasDownload(const UserPtr& aUser) throw(); @@ -187,6 +189,7 @@ bool isRunning(const UserPtr& aUser) const { return (running.find(aUser) != running.end()); } + int64_t getQueued(const UserPtr& aUser) const; private: /** QueueItems by priority and user (this is where the download order is determined) */ QueueItem::UserListMap userQueue[QueueItem::LAST]; Modified: dcplusplus/trunk/win32/ADLSProperties.cpp =================================================================== --- dcplusplus/trunk/win32/ADLSProperties.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/ADLSProperties.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -47,12 +47,12 @@ bool ADLSProperties::handleInitDialog() { // Translate dialog setText(T_("ADLSearch Properties")); - ::SetDlgItemText(handle(), IDC_ADLSP_SEARCH, CTSTRING(ADLS_SEARCH_STRING)); - ::SetDlgItemText(handle(), IDC_ADLSP_TYPE, CTSTRING(ADLS_TYPE)); - ::SetDlgItemText(handle(), IDC_ADLSP_SIZE_MIN, CTSTRING(ADLS_SIZE_MIN)); - ::SetDlgItemText(handle(), IDC_ADLSP_SIZE_MAX, CTSTRING(ADLS_SIZE_MAX)); - ::SetDlgItemText(handle(), IDC_ADLSP_UNITS, CTSTRING(ADLS_UNITS)); - ::SetDlgItemText(handle(), IDC_ADLSP_DESTINATION, CTSTRING(ADLS_DESTINATION)); + ::SetDlgItemText(handle(), IDC_ADLSP_SEARCH, CT_("Search String")); + ::SetDlgItemText(handle(), IDC_ADLSP_TYPE, CT_("Search Type")); + ::SetDlgItemText(handle(), IDC_ADLSP_SIZE_MIN, CT_("Min FileSize")); + ::SetDlgItemText(handle(), IDC_ADLSP_SIZE_MAX, CT_("Max FileSize")); + ::SetDlgItemText(handle(), IDC_ADLSP_UNITS, CT_("Size Type")); + ::SetDlgItemText(handle(), IDC_ADLSP_DESTINATION, CT_("Destination Directory")); searchString = attachTextBox(IDC_SEARCH_STRING); searchString->setText(Text::toT(search->searchString)); @@ -109,11 +109,11 @@ search->sourceType = (ADLSearch::SourceType)searchType->getSelectedIndex(); tstring minFileSize = minSize->getText(); - search->minFileSize = minFileSize.empty() ? -1 : Util::toInt64(Text::fromT(minFileSize)); + tstring maxFileSize = maxSize->getText(); - search->maxFileSize = maxFileSize.empty() ? -1 : Util::toInt64(Text::fromT(maxFileSize)); + search->typeFileSize = (ADLSearch::SizeType)sizeType->getSelectedIndex(); search->destDir = Text::fromT(destDir->getText()); Modified: dcplusplus/trunk/win32/ADLSearchFrame.cpp =================================================================== --- dcplusplus/trunk/win32/ADLSearchFrame.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/ADLSearchFrame.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -305,10 +305,10 @@ void ADLSearchFrame::addEntry(ADLSearch& search, int index) { TStringList l; l.push_back(Text::toT(search.searchString)); - l.push_back(search.SourceTypeToDisplayString(search.sourceType)); + l.push_back(Text::toT(search.SourceTypeToString(search.sourceType))); l.push_back(Text::toT(search.destDir)); - l.push_back((search.minFileSize >= 0) ? Text::toT(Util::toString(search.minFileSize)) + _T(" ") + search.SizeTypeToDisplayString(search.typeFileSize) : Util::emptyStringT); - l.push_back((search.maxFileSize >= 0) ? Text::toT(Util::toString(search.maxFileSize)) + _T(" ") + search.SizeTypeToDisplayString(search.typeFileSize) : Util::emptyStringT); + l.push_back((search.minFileSize >= 0) ? Text::toT(Util::toString(search.minFileSize)) + _T(" ") + Text::toT(search.SizeTypeToString(search.typeFileSize)) : Util::emptyStringT); + l.push_back((search.maxFileSize >= 0) ? Text::toT(Util::toString(search.maxFileSize)) + _T(" ") + Text::toT(search.SizeTypeToString(search.typeFileSize)) : Util::emptyStringT); int itemCount = items->insert(l, 0, index); if(index == -1) index = itemCount; Modified: dcplusplus/trunk/win32/AboutDlg.cpp =================================================================== --- dcplusplus/trunk/win32/AboutDlg.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/AboutDlg.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -42,7 +42,7 @@ "bsod, sulan, jonathan stone, tim burton, izzzo, guitarm, paka, nils maier, jens oknelid, yoji, " "krzysztof tyszecki, poison, mikejj, pur, bigmuscle, martin, jove, bart vullings, " "steven sheehy, tobias nygren, poy, dorian, stephan hohe, mafa_45, mikael eman, james ross," -"stanislav maslovski. " +"stanislav maslovski, david grundberg. " "Keep it coming!"; AboutDlg::AboutDlg(SmartWin::Widget* parent) : SmartWin::WidgetFactory<SmartWin::WidgetModalDialog>(parent) { @@ -63,7 +63,7 @@ sprintf(buf, "Ratio (up/down): %.2f", ((double)SETTING(TOTAL_UPLOAD)) / ((double)SETTING(TOTAL_DOWNLOAD))); setItemText(IDC_RATIO, Text::toT(buf)); } - setItemText(IDC_LATEST, CTSTRING(DOWNLOADING)); + setItemText(IDC_LATEST, T_("Downloading...")); attachButton(IDOK)->onClicked(std::tr1::bind(&AboutDlg::endDialog, this, IDOK)); Modified: dcplusplus/trunk/win32/CommandDlg.cpp =================================================================== --- dcplusplus/trunk/win32/CommandDlg.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/CommandDlg.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -62,14 +62,14 @@ bool CommandDlg::handleInitDialog() { // Translate setText(T_("Create / Modify Command")); - ::SetDlgItemText(handle(), IDC_SETTINGS_TYPE, CTSTRING(USER_CMD_TYPE)); - ::SetDlgItemText(handle(), IDC_SETTINGS_CONTEXT, CTSTRING(USER_CMD_CONTEXT)); - ::SetDlgItemText(handle(), IDC_SETTINGS_PARAMETERS, CTSTRING(USER_CMD_PARAMETERS)); - ::SetDlgItemText(handle(), IDC_SETTINGS_NAME, CTSTRING(HUB_NAME)); - ::SetDlgItemText(handle(), IDC_SETTINGS_COMMAND, CTSTRING(USER_CMD_COMMAND)); - ::SetDlgItemText(handle(), IDC_SETTINGS_HUB, CTSTRING(USER_CMD_HUB)); - ::SetDlgItemText(handle(), IDC_SETTINGS_TO, CTSTRING(USER_CMD_TO)); - ::SetDlgItemText(handle(), IDC_USER_CMD_PREVIEW, CTSTRING(USER_CMD_PREVIEW)); + ::SetDlgItemText(handle(), IDC_SETTINGS_TYPE, CT_("Command Type")); + ::SetDlgItemText(handle(), IDC_SETTINGS_CONTEXT, CT_("Context")); + ::SetDlgItemText(handle(), IDC_SETTINGS_PARAMETERS, CT_("Parameters")); + ::SetDlgItemText(handle(), IDC_SETTINGS_NAME, CT_("Name")); + ::SetDlgItemText(handle(), IDC_SETTINGS_COMMAND, CT_("Command")); + ::SetDlgItemText(handle(), IDC_SETTINGS_HUB, CT_("Hub IP / DNS (empty = all, 'op' = where operator)")); + ::SetDlgItemText(handle(), IDC_SETTINGS_TO, CT_("To")); + ::SetDlgItemText(handle(), IDC_USER_CMD_PREVIEW, CT_("Text sent to hub")); separator = attachRadioButton(IDC_SETTINGS_SEPARATOR); separator->setText(T_("Separator")); Modified: dcplusplus/trunk/win32/DirectoryListingFrame.cpp =================================================================== --- dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -655,9 +655,9 @@ } void DirectoryListingFrame::initStatusText() { - setStatus(STATUS_TOTAL_FILES, Text::toT(STRING(FILES) + ": " + Util::toString(dl->getTotalFileCount(true)))); - setStatus(STATUS_TOTAL_SIZE, Text::toT(STRING(SIZE) + ": " + Util::formatBytes(dl->getTotalSize(true)))); - setStatus(STATUS_SPEED, Text::toT(STRING(SPEED) + ": " + Util::formatBytes(speed) + "/s")); + setStatus(STATUS_TOTAL_FILES, str(TF_("Files: %1%") % dl->getTotalFileCount(true))); + setStatus(STATUS_TOTAL_SIZE, str(TF_("Size: %1%") % Text::toT(Util::formatBytes(dl->getTotalSize(true))))); + setStatus(STATUS_SPEED, str(TF_("Speed: %1%/s") % Text::toT(Util::formatBytes(speed)))); } void DirectoryListingFrame::updateStatus() { @@ -671,9 +671,9 @@ total = files->forEachSelectedT(ItemInfo::TotalSize()).total; } - setStatus(STATUS_SELECTED_FILES, Text::toT(STRING(ITEMS) + ": " + Util::toString(cnt))); + setStatus(STATUS_SELECTED_FILES, str(TF_("Files: %1%") % cnt)); - setStatus(STATUS_SELECTED_SIZE, Text::toT(STRING(SIZE) + ": " + Util::formatBytes(total))); + setStatus(STATUS_SELECTED_SIZE, str(TF_("Size: %1%") % Text::toT(Util::formatBytes(total)))); } } Modified: dcplusplus/trunk/win32/FavHubProperties.cpp =================================================================== --- dcplusplus/trunk/win32/FavHubProperties.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/FavHubProperties.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -46,14 +46,14 @@ bool FavHubProperties::handleInitDialog() { // Translate dialog setText(T_("Favorite Hub Properties")); - ::SetDlgItemText(handle(), IDC_FH_HUB, CTSTRING(HUB)); - ::SetDlgItemText(handle(), IDC_FH_IDENT, CTSTRING(FAVORITE_HUB_IDENTITY)); - ::SetDlgItemText(handle(), IDC_FH_NAME, CTSTRING(HUB_NAME)); - ::SetDlgItemText(handle(), IDC_FH_ADDRESS, CTSTRING(HUB_ADDRESS)); - ::SetDlgItemText(handle(), IDC_FH_HUB_DESC, CTSTRING(DESCRIPTION)); - ::SetDlgItemText(handle(), IDC_FH_NICK, CTSTRING(NICK)); - ::SetDlgItemText(handle(), IDC_FH_PASSWORD, CTSTRING(PASSWORD)); - ::SetDlgItemText(handle(), IDC_FH_USER_DESC, CTSTRING(DESCRIPTION)); + ::SetDlgItemText(handle(), IDC_FH_HUB, CT_("Hub")); + ::SetDlgItemText(handle(), IDC_FH_IDENT, CT_("Identification (leave blank for defaults)")); + ::SetDlgItemText(handle(), IDC_FH_NAME, CT_("Name")); + ::SetDlgItemText(handle(), IDC_FH_ADDRESS, CT_("Address")); + ::SetDlgItemText(handle(), IDC_FH_HUB_DESC, CT_("Description")); + ::SetDlgItemText(handle(), IDC_FH_NICK, CT_("Nick")); + ::SetDlgItemText(handle(), IDC_FH_PASSWORD, CT_("Password")); + ::SetDlgItemText(handle(), IDC_FH_USER_DESC, CT_("Description")); name = attachTextBox(IDC_HUBNAME); name->setText(Text::toT(entry->getName())); Modified: dcplusplus/trunk/win32/FinishedFrameBase.h =================================================================== --- dcplusplus/trunk/win32/FinishedFrameBase.h 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/FinishedFrameBase.h 2008-01-19 10:18:34 UTC (rev 967) @@ -276,9 +276,9 @@ } void updateStatus() { - setStatus(STATUS_COUNT, Text::toT(Util::toString(items->size()) + ' ' + STRING(ITEMS))); + setStatus(STATUS_COUNT, str(TFN_("%1% item", "%1% items", items->size()) % items->size())); setStatus(STATUS_BYTES, Text::toT(Util::formatBytes(totalBytes))); - setStatus(STATUS_SPEED, Text::toT(Util::formatBytes((totalTime > 0) ? totalBytes * ((int64_t)1000) / totalTime : 0) + "/s")); + setStatus(STATUS_SPEED, str(TF_("%1%/s") % Text::toT(Util::formatBytes((totalTime > 0) ? totalBytes * ((int64_t)1000) / totalTime : 0)))); } void updateList(const FinishedItemList& fl) { Modified: dcplusplus/trunk/win32/HashProgressDlg.cpp =================================================================== --- dcplusplus/trunk/win32/HashProgressDlg.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/HashProgressDlg.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -39,8 +39,8 @@ bool HashProgressDlg::handleInitDialog() { setText(T_("Creating file index...")); - ::SetDlgItemText(handle(), IDC_HASH_INDEXING, CTSTRING(HASH_PROGRESS_TEXT)); - ::SetDlgItemText(handle(), IDC_STATISTICS, CTSTRING(HASH_PROGRESS_STATS)); + ::SetDlgItemText(handle(), IDC_HASH_INDEXING, CT_("Please wait while DC++ indexes your files (they won't be shared until they've been indexed)...")); + ::SetDlgItemText(handle(), IDC_STATISTICS, CT_("Statistics")); progress = attachProgressBar(IDC_HASH_PROGRESS); progress->setRange(0, 10000); @@ -103,7 +103,7 @@ } if(files == 0) { - ::SetDlgItemText(handle(), IDC_CURRENT_FILE, CTSTRING(DONE)); + ::SetDlgItemText(handle(), IDC_CURRENT_FILE, CT_("Done")); } else { ::SetDlgItemText(handle(), IDC_CURRENT_FILE, Text::toT(file).c_str()); } Modified: dcplusplus/trunk/win32/HubFrame.cpp =================================================================== --- dcplusplus/trunk/win32/HubFrame.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/HubFrame.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -328,12 +328,11 @@ } else if(Util::stricmp(cmd.c_str(), _T("userlist")) == 0) { showUsers->setChecked(!showUsers->getChecked()); } else if(Util::stricmp(cmd.c_str(), _T("connection")) == 0) { - addStatus(Text::toT((STRING(IP) + client->getLocalIp() + ", " + - STRING(PORT) + - Util::toString(ConnectionManager::getInstance()->getPort()) + "/" + - Util::toString(SearchManager::getInstance()->getPort()) + "/" + - Util::toString(ConnectionManager::getInstance()->getSecurePort()) - ))); + addStatus(str(TF_("IP: %1%, Port: %2%/%3%/%4%") % Text::toT(client->getLocalIp()) + % ConnectionManager::getInstance()->getPort() + % SearchManager::getInstance()->getPort() + % ConnectionManager::getInstance()->getSecurePort() + )); } else if((Util::stricmp(cmd.c_str(), _T("favorite")) == 0) || (Util::stricmp(cmd.c_str(), _T("fav")) == 0)) { addAsFavorite(); } else if((Util::stricmp(cmd.c_str(), _T("removefavorite")) == 0) || (Util::stricmp(cmd.c_str(), _T("removefav")) == 0)) { @@ -379,12 +378,12 @@ if (BOOLSETTING(SEND_UNKNOWN_COMMANDS)) { client->hubMessage(Text::fromT(s)); } else { - addStatus(TSTRING(UNKNOWN_COMMAND) + cmd); + addStatus(str(TF_("Unknown command: %1%") % cmd)); } } message->setText(_T("")); } else if(waitingForPW) { - addStatus(TSTRING(DONT_REMOVE_SLASH_PASSWORD)); + addStatus(T_("Don't remove /password before your password")); message->setText(_T("/password ")); message->setFocus(); message->setSelection(10, 10); @@ -489,14 +488,14 @@ UserTask& u = *static_cast<UserTask*>(i->second); if(updateUser(u)) { if (showJoins || (favShowJoins && FavoriteManager::getInstance()->isFavoriteUser(u.user))) { - addStatus(_T("*** ") + TSTRING(JOINS) + Text::toT(u.identity.getNick())); + addStatus(str(TF_("*** Joins: %1%") % Text::toT(u.identity.getNick()))); } } } else if(i->first == REMOVE_USER) { UserTask& u = *static_cast<UserTask*>(i->second); removeUser(u.user); if (showJoins || (favShowJoins && FavoriteManager::getInstance()->isFavoriteUser(u.user))) { - addStatus(Text::toT("*** " + STRING(PARTS) + u.identity.getNick())); + addStatus(str(TF_("*** Parts: %1%") % Text::toT(u.identity.getNick()))); } } else if(i->first == CONNECTED) { addStatus(T_("Connected")); @@ -541,25 +540,25 @@ PMTask& pm = *static_cast<PMTask*>(i->second); if(pm.hub) { if(BOOLSETTING(IGNORE_HUB_PMS)) { - addStatus(TSTRING(IGNORED_MESSAGE) + Text::toT(pm.str), false); + addStatus(str(TF_("Ignored message: %1%") % Text::toT(pm.str)), false); } else if(BOOLSETTING(POPUP_HUB_PMS) || PrivateFrame::isOpen(pm.replyTo)) { PrivateFrame::gotMessage(getParent(), pm.from, pm.to, pm.replyTo, Text::toT(pm.str)); } else { - addChat(TSTRING(PRIVATE_MESSAGE_FROM) + getNick(pm.from) + _T(": ") + Text::toT(pm.str)); + addChat(str(TF_("Private message from %1%: %2%") % getNick(pm.from) % Text::toT(pm.str))); } } else if(pm.bot) { if(BOOLSETTING(IGNORE_BOT_PMS)) { - addStatus(TSTRING(IGNORED_MESSAGE) + Text::toT(pm.str), false); + addStatus(str(TF_("Ignored message: %1%") % Text::toT(pm.str)), false); } else if(BOOLSETTING(POPUP_BOT_PMS) || PrivateFrame::isOpen(pm.replyTo)) { PrivateFrame::gotMessage(getParent(), pm.from, pm.to, pm.replyTo, Text::toT(pm.str)); } else { - addChat(TSTRING(PRIVATE_MESSAGE_FROM) + getNick(pm.from) + _T(": ") + Text::toT(pm.str)); + addChat(str(TF_("Private message from %1%: %2%") % getNick(pm.from) % Text::toT(pm.str))); } } else { if(BOOLSETTING(POPUP_PMS) || PrivateFrame::isOpen(pm.replyTo) || pm.from == client->getMyIdentity().getUser()) { PrivateFrame::gotMessage(getParent(), pm.from, pm.to, pm.replyTo, Text::toT(pm.str)); } else { - addChat(TSTRING(PRIVATE_MESSAGE_FROM) + getNick(pm.from) + _T(": ") + Text::toT(pm.str)); + addChat(str(TF_("Private message from %1%: %2%") % getNick(pm.from) % Text::toT(pm.str))); } } } else if(i->first == FOLLOW) { @@ -905,7 +904,7 @@ } void HubFrame::on(NickTaken, Client*) throw() { - speak(ADD_STATUS_LINE, STRING(NICK_TAKEN)); + speak(ADD_STATUS_LINE, _("Your nick was already taken, please change to something else!")); } void HubFrame::on(SearchFlood, Client*, const string& line) throw() { @@ -935,7 +934,7 @@ textForUsers += Text::toT(Util::toString(users->getSelectedCount()) + "/"); if (showUsers->getChecked() && users->size() < userCount) textForUsers += Text::toT(Util::toString(users->size()) + "/"); - return textForUsers + Text::toT(Util::toString(userCount) + " " + STRING(HUB_USERS)); + return textForUsers + str(TFN_("%1% user", "%1% users", userCount) % userCount); } Modified: dcplusplus/trunk/win32/MagnetDlg.cpp =================================================================== --- dcplusplus/trunk/win32/MagnetDlg.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/MagnetDlg.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -43,10 +43,10 @@ bool MagnetDlg::handleInitDialog() { setText(T_("MAGNET Link detected")); - ::SetDlgItemText(handle(), IDC_MAGNET_TEXT, CTSTRING(MAGNET_DLG_TEXT_GOOD)); - ::SetDlgItemText(handle(), IDC_MAGNET_HASH, CTSTRING(MAGNET_DLG_HASH)); + ::SetDlgItemText(handle(), IDC_MAGNET_TEXT, CT_("DC++ has detected a MAGNET link with a file hash that can be searched for on the Direct Connect network. What would you like to do?")); + ::SetDlgItemText(handle(), IDC_MAGNET_HASH, CT_("File Hash:")); ::SetDlgItemText(handle(), IDC_MAGNET_DISP_HASH, mHash.c_str()); - ::SetDlgItemText(handle(), IDC_MAGNET_NAME, CTSTRING(MAGNET_DLG_FILE)); + ::SetDlgItemText(handle(), IDC_MAGNET_NAME, CT_("Filename:")); ::SetDlgItemText(handle(), IDC_MAGNET_DISP_NAME, mFileName.c_str()); //queue = attachRadioButton(IDC_MAGNET_1_QUEUE); Modified: dcplusplus/trunk/win32/MainWindow.cpp =================================================================== --- dcplusplus/trunk/win32/MainWindow.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/MainWindow.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -179,7 +179,7 @@ dcdebug("initMenu\n"); mainMenu = createMenu(false); - WidgetMenuPtr file = mainMenu->appendPopup(CTSTRING(MENU_FILE)); + WidgetMenuPtr file = mainMenu->appendPopup(T_("&File")); file->appendItem(IDC_QUICK_CONNECT, T_("&Quick Connect ...\tCtrl+Q"), std::tr1::bind(&MainWindow::handleQuickConnect, this)); file->appendItem(IDC_FOLLOW, T_("Follow last redirec&t\tCtrl+T")); @@ -197,7 +197,7 @@ file->appendSeparatorItem(); file->appendItem(IDC_EXIT, T_("E&xit"), std::tr1::bind(&MainWindow::handleExit, this)); - WidgetMenuPtr view = mainMenu->appendPopup(CTSTRING(MENU_VIEW)); + WidgetMenuPtr view = mainMenu->appendPopup(T_("&View")); view->appendItem(IDC_PUBLIC_HUBS, T_("&Public Hubs\tCtrl+P"), std::tr1::bind(&MainWindow::handleOpenWindow, this, _1)); view->appendItem(IDC_FAVORITE_HUBS, T_("&Favorite Hubs\tCtrl+F"), std::tr1::bind(&MainWindow::handleOpenWindow, this, _1)); @@ -218,7 +218,7 @@ view->appendItem(IDC_DOWNLOADS, T_("Downloads"), std::tr1::bind(&MainWindow::handleOpenWindow, this, _1)); view->appendItem(IDC_HASH_PROGRESS, T_("Indexing progress"), std::tr1::bind(&MainWindow::handleHashProgress, this)); - WidgetMenuPtr window = mainMenu->appendPopup(CTSTRING(MENU_WINDOW)); + WidgetMenuPtr window = mainMenu->appendPopup(T_("&Window")); window->appendItem(IDC_CLOSE_ALL_DISCONNECTED, T_("Close disconnected"), std::tr1::bind(&MainWindow::handleCloseWindows, this, _1)); window->appendItem(IDC_CLOSE_ALL_PM, T_("Close all PM windows"), std::tr1::bind(&MainWindow::handleCloseWindows, this, _1)); @@ -226,7 +226,7 @@ window->appendItem(IDC_CLOSE_ALL_DIR_LIST, T_("Close all file list windows"), std::tr1::bind(&MainWindow::handleCloseWindows, this, _1)); window->appendItem(IDC_CLOSE_ALL_SEARCH_FRAME, T_("Close all search windows"), std::tr1::bind(&MainWindow::handleCloseWindows, this, _1)); - WidgetMenuPtr help = mainMenu->appendPopup(TSTRING(MENU_HELP)); + WidgetMenuPtr help = mainMenu->appendPopup(T_("&Help")); help->appendItem(IDC_HELP_CONTENTS, T_("Help &Contents\tF1"), std::tr1::bind(&MainWindow::handleMenuHelp, this, _1)); help->appendSeparatorItem(); @@ -615,7 +615,7 @@ try { SearchManager::getInstance()->listen(); } catch(const Exception&) { - WidgetMessageBox().show(CTSTRING(TCP_PORT_BUSY), _T(APPNAME) _T(" ") _T(VERSIONSTRING), WidgetMessageBox::BOX_OK, WidgetMessageBox::BOX_ICONSTOP); + WidgetMessageBox().show(T_("Unable to open UDP port. Searching will not work correctly until you change settings or turn off any application that might be using the UDP port"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), WidgetMessageBox::BOX_OK, WidgetMessageBox::BOX_ICONSTOP); } } @@ -631,7 +631,7 @@ if ( FAILED(UPnP_UDPConnection->OpenPorts()) || FAILED(UPnP_TCPConnection->OpenPorts()) ) { - LogManager::getInstance()->message(STRING(UPNP_FAILED_TO_CREATE_MAPPINGS)); + LogManager::getInstance()->message(_("Failed to create port mappings. Please set up your NAT yourself.")); createMessageBox().show(T_("Failed to create port mappings. Please set up your NAT yourself."), _T(APPNAME) _T(" ") _T(VERSIONSTRING)); // We failed! thus reset the objects @@ -650,7 +650,7 @@ } else { //:-( Looks like we have to rely on the user setting the external IP manually // no need to do cleanup here because the mappings work - LogManager::getInstance()->message(STRING(UPNP_FAILED_TO_GET_EXTERNAL_IP)); + LogManager::getInstance()->message(_("Failed to get external IP via UPnP. Please set it yourself.")); createMessageBox().show(T_("Failed to get external IP via UPnP. Please set it yourself."), _T(APPNAME) _T(" ") _T(VERSIONSTRING)); } } @@ -664,7 +664,7 @@ { if (FAILED(UPnP_TCPConnection->ClosePorts()) ) { - LogManager::getInstance()->message(STRING(UPNP_FAILED_TO_REMOVE_MAPPINGS)); + LogManager::getInstance()->message(_("Failed to remove port mappings")); } delete UPnP_TCPConnection; } @@ -672,7 +672,7 @@ { if (FAILED(UPnP_UDPConnection->ClosePorts()) ) { - LogManager::getInstance()->message(STRING(UPNP_FAILED_TO_REMOVE_MAPPINGS)); + LogManager::getInstance()->message(_("Failed to remove port mappings")); } delete UPnP_UDPConnection; } Modified: dcplusplus/trunk/win32/PublicHubsFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PublicHubsFrame.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/PublicHubsFrame.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -269,8 +269,8 @@ } void PublicHubsFrame::updateStatus() { - setStatus(STATUS_HUBS, Text::toT(STRING(HUBS) + ": " + Util::toString(visibleHubs))); - setStatus(STATUS_USERS, Text::toT(STRING(USERS) + ": " + Util::toString(users))); + setStatus(STATUS_HUBS, str(TF_("Hubs: %1%") % visibleHubs)); + setStatus(STATUS_USERS, str(TF_("Users: %1%") % users)); } void PublicHubsFrame::updateDropDown() { @@ -314,13 +314,13 @@ std::auto_ptr<tstring> x(reinterpret_cast<tstring*>(lParam)); entries = FavoriteManager::getInstance()->getPublicHubs(); updateList(); - setStatus(STATUS_STATUS, ((wParam == LOADED_FROM_CACHE) ? TSTRING(HUB_LIST_LOADED_FROM_CACHE) : TSTRING(HUB_LIST_DOWNLOADED)) + _T(" (") + (*x) + _T(")")); + setStatus(STATUS_STATUS, ((wParam == LOADED_FROM_CACHE) ? T_("Hub list loaded from cache...") : str(TF_("Hub list downloaded... (%1%)") % (*x)))); } else if(wParam == STARTING) { std::auto_ptr<tstring> x(reinterpret_cast<tstring*>(lParam)); - setStatus(STATUS_STATUS, TSTRING(DOWNLOADING_HUB_LIST) + _T(" (") + (*x) + _T(")")); + setStatus(STATUS_STATUS, str(TF_("Downloading public hub list... (%1%)") % (*x))); } else if(wParam == FAILED) { std::auto_ptr<tstring> x(reinterpret_cast<tstring*>(lParam)); - setStatus(STATUS_STATUS, TSTRING(DOWNLOAD_FAILED) + (*x)); + setStatus(STATUS_STATUS, str(TF_("Download failed: %1%") % (*x))); } return 0; } @@ -456,7 +456,7 @@ } void PublicHubsFrame::handleRefresh() { - setStatus(STATUS_STATUS, CTSTRING(DOWNLOADING_HUB_LIST)); + setStatus(STATUS_STATUS, CT_("Downloading public hub list...")); FavoriteManager::getInstance()->refresh(true); updateDropDown(); } Modified: dcplusplus/trunk/win32/QueueFrame.cpp =================================================================== --- dcplusplus/trunk/win32/QueueFrame.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/QueueFrame.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -278,15 +278,14 @@ QueueItemInfo* ii = files->getData(i); total += (ii->getSize() > 0) ? ii->getSize() : 0; } - } - setStatus(STATUS_PARTIAL_COUNT, Text::toT(STRING(ITEMS) + ": " + Util::toString(cnt))); - setStatus(STATUS_PARTIAL_BYTES, Text::toT(STRING(SIZE) + ": " + Util::formatBytes(total))); + setStatus(STATUS_PARTIAL_COUNT, str(TF_("Items: %1%") % cnt)); + setStatus(STATUS_PARTIAL_BYTES, str(TF_("Size: %1%") % Text::toT(Util::formatBytes(total)))); if(dirty) { - setStatus(STATUS_TOTAL_COUNT, Text::toT(STRING(FILES) + ": " + Util::toString(queueItems))); - setStatus(STATUS_TOTAL_BYTES, Text::toT(STRING(SIZE) + ": " + Util::formatBytes(queueSize))); + setStatus(STATUS_TOTAL_COUNT, str(TF_("Files: %1%") % queueItems)); + setStatus(STATUS_TOTAL_BYTES, str(TF_("Size: %1%") % Text::toT(Util::formatBytes(queueSize)))); dirty = false; } } Modified: dcplusplus/trunk/win32/SearchFrame.cpp =================================================================== --- dcplusplus/trunk/win32/SearchFrame.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/SearchFrame.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -569,12 +569,12 @@ } results->insert(si); - setStatus(STATUS_COUNT, Text::toT(Util::toString(results->size()) + ' ' + STRING(ITEMS))); + setStatus(STATUS_COUNT, str(TFN_("%1% item", "%1% items", results->size()) % results->size())); setDirty(SettingsManager::BOLD_SEARCH); } break; case SPEAK_FILTER_RESULT: - setStatus(STATUS_FILTERED, Text::toT(Util::toString(droppedResults) + ' ' + STRING(FILTERED))); + setStatus(STATUS_FILTERED, str(TF_("%1% filtered") % droppedResults)); break; case SPEAK_HUB_ADDED: onHubAdded(reinterpret_cast<HubInfo*>(lParam)); @@ -990,10 +990,9 @@ token = Util::toString(Util::rand()); } - - SearchManager::SizeModes mode((SearchManager::SizeModes)sizeMode->getSelectedIndex()); + SearchManager::SizeModes searchMode((SearchManager::SizeModes)mode->getSelectedIndex()); if(llsize == 0) - mode = SearchManager::SIZE_DONTCARE; + searchMode = SearchManager::SIZE_DONTCARE; int ftype = fileType->getSelectedIndex(); @@ -1012,17 +1011,17 @@ lastSearches.push_back(s); } - setStatus(STATUS_STATUS, TSTRING(SEARCHING_FOR) + s + _T("...")); + setStatus(STATUS_STATUS, str(TF_("Searching for %1%...") % s)); setStatus(STATUS_COUNT, Util::emptyStringT); setStatus(STATUS_FILTERED, Util::emptyStringT); droppedResults = 0; isHash = (ftype == SearchManager::TYPE_TTH); - setText(TSTRING(SEARCH) + _T(" - ") + s); + setText(str(TF_("Search - %1%") % s)); if(SearchManager::getInstance()->okToSearch()) { SearchManager::getInstance()->search(clients, Text::fromT(s), llsize, - (SearchManager::TypeModes)ftype, mode, token); + (SearchManager::TypeModes)ftype, searchMode, token); if(BOOLSETTING(CLEAR_SEARCH)) // Only clear if the search was sent searchBox->setText(Util::emptyStringT); } else { @@ -1033,7 +1032,7 @@ setStatus(STATUS_COUNT, Util::emptyStringT); setStatus(STATUS_FILTERED, Util::emptyStringT); - setText(T_("Search") + _T(" - ") + msg); + setText(str(TF_("Search - %1%") % msg)); // Start the countdown timer initSecond(); } @@ -1048,12 +1047,12 @@ if(waitFor > 0) { tstring msg = str(TFN_("Searching too soon, next search in %1% second", "Searching too soon, next search in %1% seconds", waitFor) % waitFor); setStatus(STATUS_STATUS, msg); - setText(T_("Search") + _T(" - ") + msg); + setText(str(TF_("Search - %1%") % msg)); return true; } setStatus(STATUS_STATUS, T_("Ready to search...")); - setText(T_("Search") + _T(" - ") + T_("Ready to search...")); + setText(T_("Search - Ready to search...")); return false; } Modified: dcplusplus/trunk/win32/SpyFrame.cpp =================================================================== --- dcplusplus/trunk/win32/SpyFrame.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/SpyFrame.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -110,7 +110,7 @@ cur++; perSecond[cur] = 0; - setStatus(STATUS_AVG_PER_SECOND, Text::toT(STRING(AVERAGE) + Util::toString(x))); + setStatus(STATUS_AVG_PER_SECOND, str(TF_("Average/s: %1%") % x)); return true; } @@ -154,10 +154,10 @@ searches->resort(); } - setStatus(STATUS_TOTAL, Text::toT(STRING(TOTAL) + Util::toString(total))); - setStatus(STATUS_HITS, Text::toT(STRING(HITS) + Util::toString(ShareManager::getInstance()->getHits()))); + setStatus(STATUS_TOTAL, str(TF_("Total: %1%") % total)); + setStatus(STATUS_HITS, str(TF_("Hits: %1%") % ShareManager::getInstance()->getHits())); double ratio = total > 0 ? ((double)ShareManager::getInstance()->getHits()) / (double)total : 0.0; - setStatus(STATUS_HIT_RATIO, Text::toT(STRING(HIT_RATIO) + Util::toString(ratio))); + setStatus(STATUS_HIT_RATIO, str(TF_("Hit Ratio: %1%") % ratio)); } return 0; } Modified: dcplusplus/trunk/win32/TransferView.cpp =================================================================== --- dcplusplus/trunk/win32/TransferView.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/TransferView.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "stdafx.h" #include "TransferView.h" @@ -34,22 +33,17 @@ #include <dcpp/Download.h> #include <dcpp/Upload.h> -int TransferView::columnIndexes[] = { COLUMN_USER, COLUMN_HUB, COLUMN_STATUS, COLUMN_TIMELEFT, COLUMN_SPEED, COLUMN_FILE, COLUMN_SIZE, COLUMN_PATH, COLUMN_IP, COLUMN_RATIO, COLUMN_CID, COLUMN_CIPHER }; -int TransferView::columnSizes[] = { 150, 100, 250, 75, 75, 175, 100, 200, 50, 75, 125, 125 }; +int TransferView::columnIndexes[] = { COLUMN_USER, COLUMN_STATUS, COLUMN_SPEED, COLUMN_TRANSFERED, COLUMN_QUEUED, COLUMN_CIPHER, COLUMN_IP }; +int TransferView::columnSizes[] = { 125, 375, 150, 150, 75, 100, 100 }; static const char* columnNames[] = { N_("User"), - N_("Hub"), N_("Status"), - N_("Time left"), N_("Speed"), - N_("Filename"), - N_("Size"), - N_("Path"), - N_("IP"), - N_("Ratio"), - N_("CID"), - N_("Cipher") + N_("Transfered"), + N_("Queued"), + N_("Cipher"), + N_("IP") }; TransferView::TransferView(SmartWin::Widget* parent, SmartWin::WidgetTabView* mdi_) : @@ -103,7 +97,6 @@ } HRESULT TransferView::handleDestroy(WPARAM wParam, LPARAM lParam) { - SettingsManager::getInstance()->set(SettingsManager::MAINFRAME_ORDER, WinUtil::toString(transfers->getColumnOrder())); SettingsManager::getInstance()->set(SettingsManager::MAINFRAME_WIDTHS, WinUtil::toString(transfers->getColumnWidths())); @@ -329,10 +322,9 @@ } switch(col) { case COLUMN_STATUS: return 0; - case COLUMN_TIMELEFT: return compare(a->timeLeft, b->timeLeft); case COLUMN_SPEED: return compare(a->speed, b->speed); - case COLUMN_SIZE: return compare(a->size, b->size); - case COLUMN_RATIO: return compare(a->getRatio(), b->getRatio()); + case COLUMN_TRANSFERED: return compare(a->transfered, b->transfered); + case COLUMN_QUEUED: return compare(a->queued, b->queued); default: return lstrcmpi(a->columns[col].c_str(), b->columns[col].c_str()); } } @@ -381,6 +373,7 @@ } void TransferView::handleSearchAlternates() { +#ifdef PORT_ME int i = transfers->getNext(-1, LVNI_SELECTED); if(i != -1) { @@ -393,19 +386,38 @@ WinUtil::searchHash(tth); } } +#endif } -TransferView::ItemInfo::ItemInfo(const UserPtr& u, bool aDownload) : UserInfoBase(u), download(aDownload), transferFailed(false), - status(STATUS_WAITING), pos(0), size(0), start(0), actual(0), speed(0), timeLeft(0) +TransferView::ItemInfo::ItemInfo(const UserPtr& u, bool aDownload) : + UserInfoBase(u), + download(aDownload), + transferFailed(false), + status(STATUS_WAITING), + actual(0), + transfered(0), + queued(0), + speed(0) { columns[COLUMN_USER] = WinUtil::getNicks(u); - columns[COLUMN_HUB] = WinUtil::getHubNames(u).first; - columns[COLUMN_CID] = Text::toT(u->getCID().toBase32()); + columns[COLUMN_STATUS] = T_("Idle..."); + columns[COLUMN_TRANSFERED] = Text::toT(Util::toString(0)); + if(aDownload) { + queued = QueueManager::getInstance()->getQueued(u); + columns[COLUMN_QUEUED] = Text::toT(Util::toString(queued)); + } + } void TransferView::ItemInfo::update(const UpdateInfo& ui) { if(ui.updateMask & UpdateInfo::MASK_STATUS) { status = ui.status; + if(download) { + // Also update queued when status changes... + queued = QueueManager::getInstance()->getQueued(user); + columns[COLUMN_QUEUED] = Text::toT(Util::toString(queued)); + } + } if(ui.updateMask & UpdateInfo::MASK_STATUS_STRING) { // No slots etc from transfermanager better than disconnected from connectionmanager @@ -413,42 +425,28 @@ columns[COLUMN_STATUS] = ui.statusString; transferFailed = ui.transferFailed; } - if(ui.updateMask & UpdateInfo::MASK_SIZE) { - size = ui.size; - columns[COLUMN_SIZE] = Text::toT(Util::formatBytes(size)); + if(ui.updateMask & UpdateInfo::MASK_TRANSFERED) { + actual = ui.actual; + transfered = ui.transfered; + if(actual == transfered) { + columns[COLUMN_TRANSFERED] = Text::toT(Util::formatBytes(transfered)); + } else { + columns[COLUMN_TRANSFERED] = str(TF_("%1% (%2%, %3%%%)") + % Text::toT(Util::formatBytes(transfered)) + % Text::toT(Util::formatBytes(actual)) + % (actual * 100.0 / transfered)); + } } - if(ui.updateMask & UpdateInfo::MASK_START) { - start = ui.start; - } - if(ui.updateMask & UpdateInfo::MASK_POS) { - pos = start + ui.pos; - } - if(ui.updateMask & UpdateInfo::MASK_ACTUAL) { - actual = start + ui.actual; - columns[COLUMN_RATIO] = Text::toT(Util::toString(getRatio())); - } if(ui.updateMask & UpdateInfo::MASK_SPEED) { speed = ui.speed; if (status == STATUS_RUNNING) { - columns[COLUMN_SPEED] = Text::toT(Util::formatBytes(speed) + "/s"); + columns[COLUMN_SPEED] = str(TF_("%1%/s") % Text::toT(Util::formatBytes(speed))); } else { columns[COLUMN_SPEED] = Util::emptyStringT; } } - if(ui.updateMask & UpdateInfo::MASK_FILE) { - columns[COLUMN_FILE] = ui.file; - columns[COLUMN_PATH] = ui.path; - } - if(ui.updateMask & UpdateInfo::MASK_TIMELEFT) { - timeLeft = ui.timeLeft; - if (status == STATUS_RUNNING) { - columns[COLUMN_TIMELEFT] = Text::toT(Util::formatSeconds(timeLeft)); - } else { - columns[COLUMN_TIMELEFT] = Util::emptyStringT; - } - } if(ui.updateMask & UpdateInfo::MASK_IP) { - columns[COLUMN_IP] = ui.IP; + columns[COLUMN_IP] = ui.ip; } if(ui.updateMask & UpdateInfo::MASK_CIPHER) { columns[COLUMN_CIPHER] = ui.cipher; @@ -485,15 +483,23 @@ speak(UPDATE_ITEM, ui); } +static tstring getFile(Transfer* t) { + tstring file; + + if(t->getType() == Transfer::TYPE_TREE) { + file = str(TF_("TTH: %1%") % Text::toT(Util::getFileName(t->getPath()))); + } else { + file = Text::toT(Util::getFileName(t->getPath())); + } + return file; +} + void TransferView::on(DownloadManagerListener::Starting, Download* aDownload) throw() { UpdateInfo* ui = new UpdateInfo(aDownload->getUser(), true); ui->setStatus(ItemInfo::STATUS_RUNNING); - ui->setPos(aDownload->getPos()); - ui->setActual(aDownload->getActual()); - ui->setStart(0); - ui->setSize(aDownload->getSize()); - ui->setFile(Text::toT(aDownload->getPath())); - ui->setStatusString(T_("Download starting...")); + ui->setTransfered(aDownload->getPos(), aDownload->getActual()); + + ui->setStatusString(str(TF_("Requesting %1% (%2%)...") % getFile(aDownload) % aDownload->getSize())); ui->setCipher(Text::toT(aDownload->getUserConnection().getCipherName())); tstring country = Text::toT(Util::getIpCountry(aDownload->getUserConnection().getRemoteIp())); tstring ip = Text::toT(aDownload->getUserConnection().getRemoteIp()); @@ -502,9 +508,6 @@ } else { ui->setIP(country + _T(" (") + ip + _T(")")); } - if(aDownload->getType() == Transfer::TYPE_TREE) { - ui->file = _T("TTH: ") + ui->file; - } speak(UPDATE_ITEM, ui); } @@ -514,15 +517,9 @@ Download* d = *j; UpdateInfo* ui = new UpdateInfo(d->getUser(), true); - ui->setActual(d->getActual()); - ui->setPos(d->getPos()); - ui->setTimeLeft(d->getSecondsLeft()); + ui->setTransfered(d->getPos(), d->getActual()); ui->setSpeed(d->getAverageSpeed()); - tstring pos = Text::toT(Util::formatBytes(d->getPos())); - double percent = (double)d->getPos()*100.0/(double)d->getSize(); - tstring elapsed = Text::toT(Util::formatSeconds((GET_TICK() - d->getStart())/1000)); - tstring statusString; if(d->getUserConnection().isSecure()) { @@ -541,7 +538,11 @@ if(!statusString.empty()) { statusString += _T(" "); } - statusString += str(TF_("Downloaded %1% (%|2$.1f|%%) in %3%") % pos % percent % elapsed); + statusString += str(TF_("Downloading %1% (%2%/%3%)...") + % getFile(d) + % Text::toT(Util::formatBytes(d->getPos())) + % Text::toT(Util::formatBytes(d->getSize()))); + ui->setStatusString(statusString); tasks.add(UPDATE_ITEM, ui); @@ -553,13 +554,7 @@ void TransferView::on(DownloadManagerListener::Failed, Download* aDownload, const string& aReason) throw() { UpdateInfo* ui = new UpdateInfo(aDownload->getUser(), true, true); ui->setStatus(ItemInfo::STATUS_WAITING); - ui->setPos(0); ui->setStatusString(Text::toT(aReason)); - ui->setSize(aDownload->getSize()); - ui->setFile(Text::toT(aDownload->getPath())); - if(aDownload->getType() == Transfer::TYPE_TREE) { - ui->file = _T("TTH: ") + ui->file; - } speak(UPDATE_ITEM, ui); } @@ -568,11 +563,6 @@ UpdateInfo* ui = new UpdateInfo(aUpload->getUser(), false); ui->setStatus(ItemInfo::STATUS_RUNNING); - ui->setPos(aUpload->getPos()); - ui->setActual(aUpload->getActual()); - ui->setStart(aUpload->getPos()); - ui->setSize(aUpload->getSize()); - ui->setFile(Text::toT(aUpload->getPath())); ui->setStatusString(T_("Upload starting...")); ui->setCipher(Text::toT(aUpload->getUserConnection().getCipherName())); tstring country = Text::toT(Util::getIpCountry(aUpload->getUserConnection().getRemoteIp())); @@ -582,9 +572,6 @@ } else { ui->setIP(country + _T(" (") + ip + _T(")")); } - if(aUpload->getType() == Transfer::TYPE_TREE) { - ui->file = _T("TTH: ") + ui->file; - } speak(UPDATE_ITEM, ui); } @@ -594,15 +581,8 @@ Upload* u = *j; UpdateInfo* ui = new UpdateInfo(u->getUser(), false); - ui->setActual(u->getActual()); - ui->setPos(u->getPos()); - ui->setTimeLeft(u->getSecondsLeft()); ui->setSpeed(u->getAverageSpeed()); - tstring pos = Text::toT(Util::formatBytes(u->getPos())); - double percent = (double)u->getPos()*100.0/(double)u->getSize(); - tstring elapsed = Text::toT(Util::formatSeconds((GET_TICK() - u->getStart())/1000)); - tstring statusString; if(u->getUserConnection().isSecure()) { @@ -618,7 +598,10 @@ if(!statusString.empty()) { statusString += _T(" "); } - statusString += str(TF_("Uploaded %1% (%|2$.1f|%%) in %3%") % pos % percent % elapsed); + statusString += str(TF_("Uploading %1% (%2%/%3%)...") + % getFile(u) + % Text::toT(Util::formatBytes(u->getPos())) + % Text::toT(Util::formatBytes(u->getSize()))); ui->setStatusString(statusString); @@ -640,8 +623,7 @@ UpdateInfo* ui = new UpdateInfo(aTransfer->getUser(), !isUpload); ui->setStatus(ItemInfo::STATUS_WAITING); - ui->setPos(0); - ui->setStatusString(isUpload ? T_("Upload finished, idle...") : T_("Download finished, idle...")); + ui->setStatusString(T_("Idle...")); speak(UPDATE_ITEM, ui); } Modified: dcplusplus/trunk/win32/TransferView.h =================================================================== --- dcplusplus/trunk/win32/TransferView.h 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/TransferView.h 2008-01-19 10:18:34 UTC (rev 967) @@ -61,17 +61,12 @@ enum { COLUMN_FIRST, COLUMN_USER = COLUMN_FIRST, - COLUMN_HUB, COLUMN_STATUS, - COLUMN_TIMELEFT, COLUMN_SPEED, - COLUMN_FILE, - COLUMN_SIZE, - COLUMN_PATH, - COLUMN_IP, - COLUMN_RATIO, - COLUMN_CID, + COLUMN_TRANSFERED, + COLUMN_QUEUED, COLUMN_CIPHER, + COLUMN_IP, COLUMN_LAST }; @@ -84,21 +79,21 @@ class ItemInfo : public UserInfoBase { public: enum Status { - STATUS_RUNNING, - STATUS_WAITING + STATUS_RUNNING, ///< Transfering + STATUS_WAITING ///< Idle }; ItemInfo(const UserPtr& u, bool aDownload); bool download; bool transferFailed; + Status status; - int64_t pos; - int64_t size; - int64_t start; + int64_t actual; + int64_t transfered; + int64_t queued; int64_t speed; - int64_t timeLeft; tstring columns[COLUMN_LAST]; void update(const UpdateInfo& ui); @@ -106,7 +101,7 @@ void disconnect(); void deleteSelf() { delete this; } - double getRatio() { return (pos > 0) ? (double)actual / (double)pos : 1.0; } + double getRatio() { return (transfered > 0) ? (double)actual / (double)transfered : 1.0; } const tstring& getText(int col) const { return columns[col]; @@ -120,18 +115,12 @@ struct UpdateInfo : public Task { enum { - MASK_POS = 1 << 0, - MASK_SIZE = 1 << 1, - MASK_START = 1 << 2, - MASK_ACTUAL = 1 << 3, - MASK_SPEED = 1 << 4, - MASK_FILE = 1 << 5, - MASK_STATUS = 1 << 6, - MASK_TIMELEFT = 1 << 7, - MASK_IP = 1 << 8, - MASK_STATUS_STRING = 1 << 9, - MASK_COUNTRY = 1 << 10, - MASK_CIPHER = 1 << 11 + MASK_STATUS = 1 << 0, + MASK_STATUS_STRING = 1 << 1, + MASK_SPEED = 1 << 2, + MASK_TRANSFERED = 1 << 3, + MASK_IP = 1 << 4, + MASK_CIPHER = 1 << 5 }; bool operator==(const ItemInfo& ii) { return download == ii.download && user == ii.user; } @@ -143,27 +132,21 @@ UserPtr user; bool download; bool transferFailed; + void setStatus(ItemInfo::Status aStatus) { status = aStatus; updateMask |= MASK_STATUS; } ItemInfo::Status status; - void setPos(int64_t aPos) { pos = aPos; updateMask |= MASK_POS; } - int64_t pos; - void setSize(int64_t aSize) { size = aSize; updateMask |= MASK_SIZE; } - int64_t size; - void setStart(int64_t aStart) { start = aStart; updateMask |= MASK_START; } - int64_t start; - void setActual(int64_t aActual) { actual = aActual; updateMask |= MASK_ACTUAL; } + void setTransfered(int64_t aTransfered, int64_t aActual) { + transfered = aTransfered; actual = aActual; updateMask |= MASK_TRANSFERED; + } int64_t actual; + int64_t transfered; void setSpeed(int64_t aSpeed) { speed = aSpeed; updateMask |= MASK_SPEED; } int64_t speed; - void setTimeLeft(int64_t aTimeLeft) { timeLeft = aTimeLeft; updateMask |= MASK_TIMELEFT; } - int64_t timeLeft; void setStatusString(const tstring& aStatusString) { statusString = aStatusString; updateMask |= MASK_STATUS_STRING; } tstring statusString; - void setFile(const tstring& aFile) { file = Util::getFileName(aFile); path = Util::getFilePath(aFile); updateMask|= MASK_FILE; } - tstring file; - tstring path; - void setIP(const tstring& aIP) { IP = aIP; updateMask |= MASK_IP; } - tstring IP; + + void setIP(const tstring& aIp) { ip = aIp; updateMask |= MASK_IP; } + tstring ip; void setCipher(const tstring& aCipher) { cipher = aCipher; updateMask |= MASK_CIPHER; } tstring cipher; }; Modified: dcplusplus/trunk/win32/WinUtil.cpp =================================================================== --- dcplusplus/trunk/win32/WinUtil.cpp 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/WinUtil.cpp 2008-01-19 10:18:34 UTC (rev 967) @@ -262,31 +262,32 @@ if(Util::getAway() && param.empty()) { Util::setAway(false); Util::setManualAway(false); - status = TSTRING(AWAY_MODE_OFF); + status = T_("Away mode off"); } else { Util::setAway(true); Util::setManualAway(true); Util::setAwayMessage(Text::fromT(param)); - status = TSTRING(AWAY_MODE_ON) + Text::toT(Util::getAwayMessage()); + status = str(TF_("Away mode on: %1%") % Text::toT(Util::getAwayMessage())); } } else if(Util::stricmp(cmd.c_str(), _T("back")) == 0) { Util::setAway(false); - status = TSTRING(AWAY_MODE_OFF); + Util::setManualAway(false); + status = T_("Away mode off"); } else if(Util::stricmp(cmd.c_str(), _T("g")) == 0) { if(param.empty()) { - status = TSTRING(SPECIFY_SEARCH_STRING); + status = T_("Specify a search string"); } else { WinUtil::openLink(_T("http://www.google.com/search?q=") + Text::toT(Util::encodeURI(Text::fromT(param)))); } } else if(Util::stricmp(cmd.c_str(), _T("imdb")) == 0) { if(param.empty()) { - status = TSTRING(SPECIFY_SEARCH_STRING); + status = T_("Specify a search string"); } else { WinUtil::openLink(_T("http://www.imdb.com/find?q=") + Text::toT(Util::encodeURI(Text::fromT(param)))); } } else if(Util::stricmp(cmd.c_str(), _T("u")) == 0) { if (param.empty()) { - status = TSTRING(SPECIFY_URL); + status = T_("Specify a URL"); } else { WinUtil::openLink(Text::toT(Util::encodeURI(Text::fromT(param)))); } @@ -414,7 +415,7 @@ bi.hwndOwner = owner; bi.pszDisplayName = buf; - bi.lpszTitle = CTSTRING(CHOOSE_FOLDER); + bi.lpszTitle = CT_("Choose folder"); bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; bi.lParam = (LPARAM)target.c_str(); bi.lpfn = &browseCallbackProc; @@ -689,7 +690,7 @@ if(Util::stricmp(app.c_str(), Buf) != 0) { if (::RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("dchub"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL)) { - LogManager::getInstance()->message(STRING(ERROR_CREATING_REGISTRY_KEY_DCHUB)); + LogManager::getInstance()->message(_("Error creating dchub registry key")); return; } @@ -728,7 +729,7 @@ if(Util::stricmp(app.c_str(), Buf) != 0) { if (::RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("adc"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL)) { - LogManager::getInstance()->message(STRING(ERROR_CREATING_REGISTRY_KEY_ADC)); + LogManager::getInstance()->message(_("Error creating adc registry key")); return; } @@ -788,7 +789,7 @@ } else { // set Magnet\Location if (::RegCreateKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Magnet"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL)) { - LogManager::getInstance()->message(STRING(ERROR_CREATING_REGISTRY_KEY_MAGNET)); + LogManager::getInstance()->message(_("Error creating magnet registry key")); return; } @@ -801,10 +802,10 @@ if(BOOLSETTING(MAGNET_REGISTER) && (Util::strnicmp(openCmd, magnetLoc, magnetLoc.size()) != 0 || !haveMagnet)) { SHDeleteKey(HKEY_CLASSES_ROOT, _T("magnet")); if (::RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("magnet"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL)) { - LogManager::getInstance()->message(STRING(ERROR_CREATING_REGISTRY_KEY_MAGNET)); + LogManager::getInstance()->message(_("Error creating magnet registry key")); return; } - ::RegSetValueEx(hk, NULL, NULL, REG_SZ, (LPBYTE)CTSTRING(MAGNET_SHELL_DESC), sizeof(TCHAR)*(T_("URL:MAGNET URI").length()+1)); + ::RegSetValueEx(hk, NULL, NULL, REG_SZ, (LPBYTE)CT_("URL:MAGNET URI"), sizeof(TCHAR)*(T_("URL:MAGNET URI").length()+1)); ::RegSetValueEx(hk, _T("URL Protocol"), NULL, REG_SZ, NULL, NULL); ::RegCloseKey(hk); ::RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("magnet\\DefaultIcon"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL); @@ -820,8 +821,8 @@ SHDeleteKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Magnet\\Handlers\\DC++")); // add DC++ to magnet-handler's list of applications ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Magnet\\Handlers\\DC++"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL); - ::RegSetValueEx(hk, NULL, NULL, REG_SZ, (LPBYTE)CTSTRING(MAGNET_HANDLER_ROOT), sizeof(TCHAR) * (T_("DC++").size()+1)); - ::RegSetValueEx(hk, _T("Description"), NULL, REG_SZ, (LPBYTE)CTSTRING(MAGNET_HANDLER_DESC), sizeof(TCHAR) * (STRING(MAGNET_HANDLER_DESC).size()+1)); + ::RegSetValueEx(hk, NULL, NULL, REG_SZ, (LPBYTE)CT_("DC++"), sizeof(TCHAR) * (T_("DC++").size()+1)); + ::RegSetValueEx(hk, _T("Description"), NULL, REG_SZ, (LPBYTE)CT_("Download files from the Direct Connect network"), sizeof(TCHAR) * (T_("Download files from the Direct Connect network").size()+1)); // set ShellExecute tstring app = Text::toT("\"" + getAppName() + "\" %URL"); ::RegSetValueEx(hk, _T("ShellExecute"), NULL, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR) * (app.length()+1)); @@ -1035,15 +1036,15 @@ double WinUtil::toBytes(TCHAR* aSize) { double bytes = _tstof(aSize); - if (_tcsstr(aSize, CTSTRING(PIB))) { + if (_tcsstr(aSize, CT_("PiB"))) { return bytes * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0; - } else if (_tcsstr(aSize, CTSTRING(TiB))) { + } else if (_tcsstr(aSize, CT_("TiB"))) { return bytes * 1024.0 * 1024.0 * 1024.0 * 1024.0; - } else if (_tcsstr(aSize, CTSTRING(GiB))) { + } else if (_tcsstr(aSize, CT_("GiB"))) { return bytes * 1024.0 * 1024.0 * 1024.0; - } else if (_tcsstr(aSize, CTSTRING(MiB))) { + } else if (_tcsstr(aSize, CT_("MiB"))) { return bytes * 1024.0 * 1024.0; - } else if (_tcsstr(aSize, CTSTRING(KiB))) { + } else if (_tcsstr(aSize, CT_("KiB"))) { return bytes * 1024.0; } else { return bytes; Modified: dcplusplus/trunk/win32/stdafx.h =================================================================== --- dcplusplus/trunk/win32/stdafx.h 2008-01-17 21:48:59 UTC (rev 966) +++ dcplusplus/trunk/win32/stdafx.h 2008-01-19 10:18:34 UTC (rev 967) @@ -50,6 +50,7 @@ #define gettext_noop(String) String #define N_(String) gettext_noop (String) #define T_(String) Text::toT(gettext(String)) +#define CT_(String) T_(String).c_str() #ifdef UNICODE #define TF_(String) boost::wformat(Text::toT(gettext(String))) #define TFN_(String1,String2, N) boost::wformat(Text::toT(ngettext(String1, String2, N))) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |