diff options
author | George Hazan <george.hazan@gmail.com> | 2013-09-10 09:51:26 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-09-10 09:51:26 +0000 |
commit | 978f1a8b1ab79642c7ff4301ca00aff6eb4a2890 (patch) | |
tree | 398df9a4376f37edd22b652426a468d50ba7f8c5 /protocols | |
parent | 2e7712a526556ead476ead3083039417f7eba863 (diff) |
obsolete function ThreadData::send(...) removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@6040 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/JabberG/src/jabber.h | 4 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_file.cpp | 61 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 33 |
3 files changed, 34 insertions, 64 deletions
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h index 585f434a88..20371a9e30 100644 --- a/protocols/JabberG/src/jabber.h +++ b/protocols/JabberG/src/jabber.h @@ -390,8 +390,8 @@ struct ThreadData void close(void);
void shutdown(void);
int recv(char* buf, size_t len);
- int send(char* buffer, int bufsize);
- int send(const char* fmt, ...);
+ int send(char* buffer, int bufsize = -1);
+// int send(const char* fmt, ...);
int send(HXML node);
int recvws(char* buffer, size_t bufsize, int flags);
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 62d1fa49ef..d00b2324bc 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -28,21 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft)
{
- char* buffer;
- int datalen;
ThreadData info(this, JABBER_SESSION_NORMAL);
Log("Thread started: type=file_receive server='%s' port='%d'", ft->httpHostName, ft->httpPort);
ft->type = FT_OOB;
- if ((buffer=(char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == NULL) {
- Log("Cannot allocate network buffer, thread ended");
- ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
- delete ft;
- return;
- }
-
NETLIBOPENCONNECTION nloc = { 0 };
nloc.cbSize = sizeof(nloc);
nloc.cbSize = sizeof(NETLIBOPENCONNECTION);
@@ -52,42 +43,40 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft) if (info.s == NULL) {
Log("Connection failed (%d), thread ended", WSAGetLastError());
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
- mir_free(buffer);
- delete ft;
- return;
}
+ else {
+ ft->s = info.s;
- ft->s = info.s;
-
- info.send("GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", ft->httpPath, ft->httpHostName);
- ft->state = FT_CONNECTING;
-
- Log("Entering file_receive recv loop");
- datalen = 0;
+ char buffer[JABBER_NETWORK_BUFFER_SIZE];
+ int datalen = mir_snprintf(buffer, SIZEOF(buffer), "GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", ft->httpPath, ft->httpHostName);
+ info.send(buffer, datalen);
+ ft->state = FT_CONNECTING;
- while (ft->state != FT_DONE && ft->state != FT_ERROR) {
- int recvResult, bytesParsed;
+ Log("Entering file_receive recv loop");
- Log("Waiting for data...");
- recvResult = info.recv(buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen);
- if (recvResult <= 0)
- break;
- datalen += recvResult;
+ datalen = 0;
+ while (ft->state != FT_DONE && ft->state != FT_ERROR) {
+ int recvResult, bytesParsed;
- bytesParsed = FileReceiveParse(ft, buffer, datalen);
- if (bytesParsed < datalen)
- memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
- datalen -= bytesParsed;
- }
+ Log("Waiting for data...");
+ recvResult = info.recv(buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen);
+ if (recvResult <= 0)
+ break;
+ datalen += recvResult;
- ft->s = NULL;
+ bytesParsed = FileReceiveParse(ft, buffer, datalen);
+ if (bytesParsed < datalen)
+ memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
+ datalen -= bytesParsed;
+ }
- if (ft->state==FT_DONE || (ft->state==FT_RECEIVING && ft->std.currentFileSize < 0))
- ft->complete();
+ ft->s = NULL;
- Log("Thread ended: type=file_receive server='%s'", ft->httpHostName);
+ if (ft->state==FT_DONE || (ft->state==FT_RECEIVING && ft->std.currentFileSize < 0))
+ ft->complete();
- mir_free(buffer);
+ Log("Thread ended: type=file_receive server='%s'", ft->httpHostName);
+ }
delete ft;
}
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 859f6d2c57..0ded9a90c9 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -2040,10 +2040,12 @@ int ThreadData::send(char* buffer, int bufsize) if (this == NULL)
return 0;
- int result;
+ if (bufsize == -1)
+ bufsize = strlen(buffer);
WaitForSingleObject(iomutex, 6000);
+ int result;
if (useZlib)
result = zlibSend(buffer, bufsize);
else
@@ -2073,7 +2075,7 @@ int ThreadData::send(HXML node) TCHAR *q = str;
for (TCHAR *p = str; *p; ++p) {
- WCHAR c = *p;
+ WCHAR c = *p;
if (c < 0x9 || c > 0x9 && c < 0xA || c > 0xA && c < 0xD || c > 0xD && c < 0x20 || c > 0xD7FF && c < 0xE000 || c > 0xFFFD)
continue;
@@ -2083,31 +2085,10 @@ int ThreadData::send(HXML node) *q = 0;
- char* utfStr = mir_utf8encodeT(str);
- int result = send(utfStr, (int)strlen(utfStr));
- mir_free(utfStr);
+ char* utfStr = mir_utf8encodeT(str);
+ int result = send(utfStr, (int)strlen(utfStr));
+ mir_free(utfStr);
xi.freeMem(str);
return result;
}
-
-int ThreadData::send(const char* fmt, ...)
-{
- if (this == NULL)
- return 0;
-
- va_list vararg;
- va_start(vararg, fmt);
- int size = 512;
- char* str = (char*)mir_alloc(size);
- while (mir_vsnprintf(str, size, fmt, vararg) == -1) {
- size += 512;
- str = (char*)mir_realloc(str, size);
- }
- va_end(vararg);
-
- int result = send(str, (int)strlen(str));
-
- mir_free(str);
- return result;
-}
|