Advertisement
Guest User

Untitled

a guest
Jun 20th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.07 KB | None | 0 0
  1. diff -u orig/ClientManager.cpp air/ClientManager.cpp
  2. --- orig/ClientManager.cpp 2012-04-17 20:47:29.465714900 +0200
  3. +++ air/ClientManager.cpp 2012-04-17 21:11:34.494365800 +0200
  4. @@ -582,21 +582,22 @@
  5. }
  6. }
  7.  
  8. -void ClientManager::search(StringList& who, int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList) {
  9. +void ClientManager::search(string& who, int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList) {
  10. Lock l(cs);
  11. - auto i = clients.find(const_cast<string*>(&who));
  12. - if(i != clients.end() && i->second->isConnected()) {
  13. - return i->second->search(aSizeMode, aSize, aFileType, aString, aToken, aExtList);
  14. + for(auto i = clients.begin(); i != clients.end(); ++i) { //change clients set to map<string*(hubUrl), Client*> for better lookup with .find
  15. + if(((*i)->getHubUrl() == who) && (*i)->isConnected()) {
  16. + (*i)->search(aSizeMode, aSize, aFileType, aString, aToken, aExtList);
  17. + break;
  18. + }
  19. }
  20. - return 0;
  21. }
  22.  
  23. void ClientManager::getOnlineClients(StringList& onlineClients) {
  24. Lock l (cs);
  25. - for_each(clients, [&](pair<string*, Client*> cp) {
  26. - if (cp.second->isConnected())
  27. - onlineClients.push_back(cp.second->getHubUrl());
  28. - });
  29. + for(auto i = clients.begin(); i != clients.end(); ++i) {
  30. + if((*i)->isConnected())
  31. + onlineClients.push_back((*i)->getHubUrl());
  32. + }
  33. }
  34.  
  35. void ClientManager::on(TimerManagerListener::Minute, uint64_t /* aTick */) noexcept {
  36. diff -u orig/ClientManager.h air/ClientManager.h
  37. --- orig/ClientManager.h 2012-04-17 20:45:33.924106300 +0200
  38. +++ air/ClientManager.h 2012-04-17 20:55:55.273645500 +0200
  39. @@ -88,7 +88,7 @@
  40. bool isConnected(const string& aUrl) const;
  41.  
  42. void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken);
  43. - void search(StringList& who, int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList);
  44. + void search(string& who, int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList);
  45. void infoUpdated();
  46.  
  47. UserPtr getUser(const string& aNick, const string& aHubUrl) noexcept;
  48. diff -u orig/ConnectionManager.cpp air/ConnectionManager.cpp
  49. --- orig/ConnectionManager.cpp 2012-04-14 15:42:56.094440200 +0200
  50. +++ air/ConnectionManager.cpp 2012-04-14 15:44:01.422176800 +0200
  51. @@ -70,7 +70,7 @@
  52. if(i == downloads.end()) {
  53. getCQI(aUser, true);
  54. } else {
  55. - DownloadManager::getInstance()->checkIdle(aUser.user);
  56. + DownloadManager::getInstance()->checkIdle(aUser);
  57. }
  58. }
  59. }
  60. diff -u orig/Download.cpp air/Download.cpp
  61. --- orig/Download.cpp 2012-04-14 15:30:01.953161900 +0200
  62. +++ air/Download.cpp 2012-04-14 15:33:53.029378700 +0200
  63. @@ -64,7 +64,7 @@
  64. getUserConnection().setDownload(0);
  65. }
  66.  
  67. -AdcCommand Download::getCommand(bool zlib, bool enabler) {
  68. +AdcCommand Download::getCommand(bool zlib, const string& mySID, bool enabler) {
  69. AdcCommand cmd(AdcCommand::CMD_GET);
  70.  
  71. if(enabler) {
  72. diff -u orig/Download.h air/Download.h
  73. --- orig/Download.h 2012-04-14 14:47:57.618000000 +0200
  74. +++ air/Download.h 2012-04-14 15:34:32.469634500 +0200
  75. @@ -67,7 +67,7 @@
  76. TigerTree& getTigerTree() { return tt; }
  77. const string& getPFS() const { return pfs; }
  78. /** @internal */
  79. - AdcCommand getCommand(bool zlib, bool enable = false);
  80. + AdcCommand getCommand(bool zlib, const string& mySID, bool enable = false);
  81.  
  82. const unique_ptr<OutputStream>& getOutput() const { return output; }
  83.  
  84. diff -u orig/DownloadManager.cpp air/DownloadManager.cpp
  85. --- orig/DownloadManager.cpp 2012-04-14 15:32:39.412168000 +0200
  86. +++ air/DownloadManager.cpp 2012-04-17 19:55:45.164159000 +0200
  87. @@ -20,6 +20,7 @@
  88. #include "DownloadManager.h"
  89.  
  90. #include "QueueManager.h"
  91. +#include "ClientManager.h"
  92. #include "Download.h"
  93. #include "LogManager.h"
  94. #include "User.h"
  95. @@ -105,11 +106,13 @@
  96. }
  97. }
  98.  
  99. -void DownloadManager::checkIdle(const UserPtr& user) {
  100. +void DownloadManager::checkIdle(const HintedUser& user) {
  101. Lock l(cs);
  102. for(auto i = idlers.begin(); i != idlers.end(); ++i) {
  103. UserConnection* uc = *i;
  104. - if(uc->getUser() == user) {
  105. + if(uc->getUser() == user.user) {
  106. + if(Util::stricmp(uc->getHubUrl(), user.hint) != 0)
  107. + uc->setHubUrl(user.hint);
  108. uc->updated();
  109. return;
  110. }
  111. diff -u orig/DownloadManager.h air/DownloadManager.h
  112. --- orig/DownloadManager.h 2012-04-14 14:47:57.618000000 +0200
  113. +++ air/DownloadManager.h 2012-04-14 15:40:10.024941600 +0200
  114. @@ -43,7 +43,7 @@
  115.  
  116. /** @internal */
  117. void addConnection(UserConnectionPtr conn);
  118. - void checkIdle(const UserPtr& user);
  119. + void checkIdle(const HintedUser& user);
  120.  
  121. /** @return Running average download speed in Bytes/s */
  122. int64_t getRunningAverage();
  123. diff -u orig/SearchManager.cpp air/SearchManager.cpp
  124. --- orig/SearchManager.cpp 2012-04-17 21:28:40.646058400 +0200
  125. +++ air/SearchManager.cpp 2012-04-18 19:21:12.111384500 +0200
  126. @@ -340,8 +340,8 @@
  127. Lock l (cs);
  128. auto i = searches.find(token);
  129. if (i != searches.end()) {
  130. - localToken = get<LOCALTOKEN>((*i).second);
  131. - hub = get<HUBURL>((*i).second);
  132. + localToken = boost::get<LOCALTOKEN>((*i).second);
  133. + hub = boost::get<HUBURL>((*i).second);
  134. }
  135. }
  136. SearchResult::Types type = (file[file.length() - 1] == '\\' ? SearchResult::TYPE_DIRECTORY : SearchResult::TYPE_FILE);
  137. @@ -349,7 +349,7 @@
  138. return;
  139. /// @todo Something about the slots
  140. SearchResultPtr sr(new SearchResult(from, type, 0, freeSlots, size,
  141. - file, hubName, hub, remoteIp, TTHValue(tth), token));
  142. + file, hubName, hub, remoteIp, TTHValue(tth), localToken));
  143. fire(SearchManagerListener::SR(), sr);
  144. }
  145. }
  146. diff -u orig/SearchManager.h air/SearchManager.h
  147. --- orig/SearchManager.h 2012-04-17 21:16:24.370945800 +0200
  148. +++ air/SearchManager.h 2012-04-17 21:16:28.241167200 +0200
  149. @@ -106,6 +106,7 @@
  150. uint64_t lastSearch;
  151. friend class Singleton<SearchManager>;
  152. CriticalSection cs;
  153. +
  154. SearchManager();
  155.  
  156. static std::string normalizeWhitespace(const std::string& aString);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement