diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2011-03-22 02:16:45 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2011-03-22 02:16:45 +0200 |
commit | b0e1bb306eec7f2d13ff385d4c1191646cc3e7f9 (patch) | |
tree | 359bfaab5e9fd2fd49a740aceff1e5573e0aba15 /utilities.cpp | |
parent | be35d4a3d07f44604ad71e6c6997c47f8b5bcdde (diff) | |
parent | 6fc50b0001b4edb38f1a6d194a43d5622a0a0f94 (diff) |
Merge branch 'new_gpg' into new_gpg_autoexchange
Diffstat (limited to 'utilities.cpp')
-rw-r--r-- | utilities.cpp | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/utilities.cpp b/utilities.cpp index 115c2bf..0ba8e12 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -272,9 +272,12 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM l) list<wstring> transfers; +extern bool bFileTransfers; int onProtoAck(WPARAM w, LPARAM l) { + if(!bFileTransfers) + return 0; ACKDATA *ack=(ACKDATA*)l; CCSDATA *ccs=(CCSDATA*)ack->lParam; if (ack->type!=ACKTYPE_FILE) @@ -292,19 +295,21 @@ int onProtoAck(WPARAM w, LPARAM l) case ACKRESULT_SUCCESS: { TCHAR *filename = NULL; -// if(f->szCurrentFile && f->szCurrentFile[0]) -// filename = mir_utf8decodeW(f->szCurrentFile); - if(f->tszCurrentFile && f->tszCurrentFile[0]) - filename = mir_wstrdup(f->tszCurrentFile); - if(!filename) - break; - TCHAR *temp = _wgetenv(_T("TEMP")); - if(_tcsstr(filename, temp)) + if(f->flags & PFTS_UNICODE) { - mir_free(filename); - break; + if(f->tszCurrentFile && f->tszCurrentFile[0]) + filename = mir_wstrdup(f->tszCurrentFile); + if(!filename) + return 0; + } + else + { + if(f->szCurrentFile && f->szCurrentFile[0]) + filename = mir_utf8decodeT(f->szCurrentFile); + if(!filename) + return 0; } - else if(_tcsstr(filename, _T(".gpg"))) //decrypt it + if(_tcsstr(filename, _T(".gpg"))) //decrypt it { //process encrypted file if(_waccess(f->tszCurrentFile, 0) == -1) { @@ -351,10 +356,11 @@ int onProtoAck(WPARAM w, LPARAM l) return 0; } - //from secureim partially int onSendFile(WPARAM w, LPARAM l) { + if(!bFileTransfers) + return CallService(MS_PROTO_CHAINSEND, w, l); CCSDATA *ccs=(CCSDATA*)l; if(isContactSecured(ccs->hContact)) { @@ -364,6 +370,9 @@ int onSendFile(WPARAM w, LPARAM l) { if (_tcsstr(file[i],_T(".gpg"))) continue; + if(_waccess(file[i], 0) == -1) + if(errno == ENOENT) + return 0; //we do not want to send file unencrypted (sometimes ack have wrong info) TCHAR *name = _tcsrchr(file[i],_T('\\')); if( !name ) name = file[i]; @@ -383,7 +392,7 @@ int onSendFile(WPARAM w, LPARAM l) mir_free(szKeyid); mir_free(keyid); cmd += _T(" -o \""); - TCHAR *temp = _wgetenv(_T("TEMP")); + TCHAR *temp = _tgetenv(_T("TEMP")); cmd += temp; cmd += _T("\\"); cmd += file_out; @@ -430,13 +439,15 @@ int onSendFile(WPARAM w, LPARAM l) } } } - mir_free(file[i]); - file[i]=mir_wstrdup(path_out.c_str()); +// mir_free(file[i]); +// file[i] = mir_tstrdup(path_out.c_str()); + mir_realloc(file[i], path_out.length()*sizeof(TCHAR)+1); + _tcscpy(file[i], path_out.c_str()); delete [] file_out; transfers.push_back(path_out); } } - return CallService(ccs->szProtoService, w, l); + return CallService(MS_PROTO_CHAINSEND, w, l); } void storeOutput(HANDLE ahandle, string *output) @@ -964,20 +975,10 @@ int returnNoError(HANDLE hContact) { string toUTF8(wstring str) { string ustr; - wstring tmpstr; - utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr)); - utf8::utf16to8(tmpstr.begin(), tmpstr.end(), back_inserter(ustr)); + utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr)); return ustr; } -string toUTF8(string str) -{ - string ustr; - wstring tmpstr; - utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr)); - utf8::utf16to8(tmpstr.begin(), tmpstr.end(), back_inserter(ustr)); - return ustr; -} wstring toUTF16(string str) //convert as much as possible |