diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-01 19:37:35 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-01 19:37:35 +0000 |
commit | 754c5e27f878dc4a46131593e00e78e054faa995 (patch) | |
tree | e49b137bf04d56c58c50f5fb1760a6cf84bca658 /plugins/SecureIM/src/splitmsg.cpp | |
parent | 14ad5bd238bb3fb2edf8284a1c35f175e2f31d5f (diff) |
SecureIM:
- thread cleaning;
- fix SRMM status icon;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@4278 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SecureIM/src/splitmsg.cpp')
-rw-r--r-- | plugins/SecureIM/src/splitmsg.cpp | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/plugins/SecureIM/src/splitmsg.cpp b/plugins/SecureIM/src/splitmsg.cpp index 74583df741..a21cb8ef44 100644 --- a/plugins/SecureIM/src/splitmsg.cpp +++ b/plugins/SecureIM/src/splitmsg.cpp @@ -2,11 +2,10 @@ // разбивает сообщение szMsg на части длиной iLen, возвращает строку вида PARTzPARTzz
-LPSTR splitMsg(LPSTR szMsg, int iLen) {
-
-#if defined(_DEBUG) || defined(NETLIB_LOG)
+LPSTR splitMsg(LPSTR szMsg, int iLen)
+{
Sent_NetLog("split: msg: -----\n%s\n-----\n",szMsg);
-#endif
+
int len = (int)strlen(szMsg);
LPSTR out = (LPSTR) mir_alloc(len*2);
LPSTR buf = out;
@@ -20,9 +19,9 @@ LPSTR splitMsg(LPSTR szMsg, int iLen) { mir_snprintf(buf,32,"%s%04X%02X%02X",SIG_SECP,msg_id,part_num,part_all);
memcpy(buf+LEN_SECP+8,szMsg,sz);
*(buf+LEN_SECP+8+sz) = '\0';
-#if defined(_DEBUG) || defined(NETLIB_LOG)
+
Sent_NetLog("split: part: %s",buf);
-#endif
+
buf += LEN_SECP+8+sz+1;
szMsg += sz;
len -= sz;
@@ -33,16 +32,15 @@ LPSTR splitMsg(LPSTR szMsg, int iLen) { // собираем сообщение из частей, части храним в структуре у контакта
-LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) {
-
-#if defined(_DEBUG) || defined(NETLIB_LOG)
+LPSTR combineMessage(pUinKey ptr, LPSTR szMsg)
+{
Sent_NetLog("combine: part: %s",szMsg);
-#endif
+
int msg_id,part_num,part_all;
sscanf(szMsg,"%4X%2X%2X",&msg_id,&part_num,&part_all);
//
pPM ppm = NULL, pm = ptr->msgPart;
- if ( !ptr->msgPart ) {
+ if (!ptr->msgPart) {
pm = ptr->msgPart = new partitionMessage;
memset(pm,0,sizeof(partitionMessage));
pm->id = msg_id;
@@ -51,7 +49,7 @@ LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { }
else
while(pm) {
- if ( pm->id == msg_id ) break;
+ if (pm->id == msg_id ) break;
ppm = pm; pm = pm->nextMessage;
}
if (!pm) { // nothing to found
@@ -63,18 +61,18 @@ LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { }
pm->message[part_num] = new char[strlen(szMsg)];
strcpy(pm->message[part_num],szMsg+8);
-#if defined(_DEBUG) || defined(NETLIB_LOG)
+
Sent_NetLog("combine: save part: %s",pm->message[part_num]);
-#endif
+
int len=0,i;
- for ( i=0; i<part_all; i++ ) {
- if (pm->message[i]==NULL) break;
+ for ( i=0; i<part_all; i++) {
+ if (pm->message[i] == NULL) break;
len+=(int)strlen(pm->message[i]);
}
- if ( i==part_all ) { // combine message
+ if (i == part_all) { // combine message
SAFE_FREE(ptr->tmp);
ptr->tmp = (LPSTR) mir_alloc(len+1); *(ptr->tmp)='\0';
- for ( i=0; i<part_all; i++ ) {
+ for ( i=0; i<part_all; i++) {
strcat(ptr->tmp,pm->message[i]);
delete pm->message[i];
}
@@ -82,16 +80,14 @@ LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { if (ppm) ppm->nextMessage = pm->nextMessage;
else ptr->msgPart = pm->nextMessage;
delete pm;
-#if defined(_DEBUG) || defined(NETLIB_LOG)
+
Sent_NetLog("combine: all parts: -----\n%s\n-----\n", ptr->tmp);
-#endif
- // собрали одно сообщение
+ // combined one message
return ptr->tmp;
}
-#if defined(_DEBUG) || defined(NETLIB_LOG)
+
Sent_NetLog("combine: not all parts");
-#endif
- // еще не собрали
+ // not combined yet
return NULL;
}
@@ -101,11 +97,11 @@ int splitMessageSend(pUinKey ptr, LPSTR szMsg) { int ret;
int len = (int)strlen(szMsg);
- int par = (getContactStatus(ptr->hContact)==ID_STATUS_OFFLINE)?ptr->proto->split_off:ptr->proto->split_on;
- if ( par && len>par ) {
+ int par = (getContactStatus(ptr->hContact) == ID_STATUS_OFFLINE)?ptr->proto->split_off:ptr->proto->split_on;
+ if (par && len>par) {
LPSTR msg = splitMsg(szMsg,par);
LPSTR buf = msg;
- while( *buf ) {
+ while( *buf) {
len = (int)strlen(buf);
LPSTR tmp = mir_strdup(buf);
ret = CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)tmp);
|