diff options
author | Szymon Tokarz <wsx22@o2.pl> | 2012-10-21 22:53:31 +0000 |
---|---|---|
committer | Szymon Tokarz <wsx22@o2.pl> | 2012-10-21 22:53:31 +0000 |
commit | d14590f9a60a4ba217ba379273c9d41c1293ca82 (patch) | |
tree | 5b643f9ef723bd797935e8bfadbb408ffc156ba3 | |
parent | b5bea6ef18bd33fbb424ae9f909c119496463d02 (diff) |
Gadu-Gadu protocol
- contact's avatars requesting fix
- images transfer fix
- some fixes in TCHAR handling
should fix #5, #15 and #45
git-svn-id: http://svn.miranda-ng.org/main/trunk@2038 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 11 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/core.cpp | 8 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg.cpp | 14 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg.h | 2 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg_proto.cpp | 8 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/image.cpp | 12 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/import.cpp | 2 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/libgadu/libgadu.h | 2 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/userutils.cpp | 8 |
9 files changed, 39 insertions, 28 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index ace7871b6a..46b41361c3 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -41,7 +41,7 @@ void GGPROTO::getAvatarFilename(HANDLE hContact, TCHAR *pszDest, int cbLen) }
if (_taccess(pszDest, 0))
- CallService(MS_UTILS_CREATEDIRTREE, 0, (LPARAM)pszDest);
+ CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)pszDest);
switch (db_get_b(hContact, m_szModuleName, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE)) {
case PA_FORMAT_JPEG: avatartype = _T("jpg"); break;
@@ -52,11 +52,14 @@ void GGPROTO::getAvatarFilename(HANDLE hContact, TCHAR *pszDest, int cbLen) if (hContact != NULL) {
DBVARIANT dbv;
if (!db_get_s(hContact, m_szModuleName, GG_KEY_AVATARHASH, &dbv, DBVT_ASCIIZ)) {
- mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s.%s"), dbv.pszVal, avatartype);
+ TCHAR* avatarHashT = mir_a2t(dbv.pszVal);
+ mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s.%s"), avatarHashT, avatartype);
+ mir_free(avatarHashT);
DBFreeVariant(&dbv);
}
- }
- else mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s avatar.%s"), m_szModuleName, avatartype);
+ } else {
+ mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s avatar.%s"), m_tszUserName, avatartype);
+ }
}
void GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, int *type)
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 63d5d37b24..55d023e12a 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -359,7 +359,9 @@ void __cdecl GGPROTO::mainthread(void *) if (!(p.external_addr = gg_dnslookup(this, dbv.pszVal)))
{
TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("External direct connections hostname %S is invalid. Disabling external host forwarding."), dbv.pszVal);
+ TCHAR* forwardHostT = mir_a2t(dbv.pszVal);
+ mir_sntprintf(error, SIZEOF(error), TranslateT("External direct connections hostname %S is invalid. Disabling external host forwarding."), forwardHostT);
+ mir_free(forwardHostT);
showpopup(m_tszUserName, error, GG_POPUP_WARNING | GG_POPUP_ALLOW_MSGBOX);
}
else
@@ -387,7 +389,9 @@ retry: if (!(p.server_addr = gg_dnslookup(this, hosts[hostnum].hostname)))
{
TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("Server hostname %S is invalid. Using default hostname provided by the network."), hosts[hostnum].hostname);
+ TCHAR* hostnameT = mir_a2t(hosts[hostnum].hostname);
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Server hostname %S is invalid. Using default hostname provided by the network."), hostnameT);
+ mir_free(hostnameT);
showpopup(m_tszUserName, error, GG_POPUP_WARNING | GG_POPUP_ALLOW_MSGBOX);
}
else
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index 5bd9f6ceb5..b75b439af0 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -113,23 +113,23 @@ unsigned long crc_get(char *mem) // http_error_string()
//
// returns http error text
-const char *http_error_string(int h)
+const TCHAR *http_error_string(int h)
{
switch (h)
{
case 0:
- return Translate((errno == ENOMEM) ? "HTTP failed memory" : "HTTP failed connecting");
+ return (errno == ENOMEM) ? TranslateT("HTTP failed memory") : TranslateT("HTTP failed connecting");
case GG_ERROR_RESOLVING:
- return Translate("HTTP failed resolving");
+ return TranslateT("HTTP failed resolving");
case GG_ERROR_CONNECTING:
- return Translate("HTTP failed connecting");
+ return TranslateT("HTTP failed connecting");
case GG_ERROR_READING:
- return Translate("HTTP failed reading");
+ return TranslateT("HTTP failed reading");
case GG_ERROR_WRITING:
- return Translate("HTTP failed writing");
+ return TranslateT("HTTP failed writing");
}
- return Translate("Unknown HTTP error");
+ return TranslateT("Unknown HTTP error");
}
//////////////////////////////////////////////////////////
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index 742f06b093..330f03c8cc 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -307,7 +307,7 @@ extern PLUGININFOEX pluginInfo; // Methods
/* Helper functions */
-const char *http_error_string(int h);
+const TCHAR *http_error_string(int h);
unsigned long crc_get(char *mem);
int gg_normalizestatus(int status);
char *gg_status2db(int status, const char *suffix);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 0a0db3a173..1659f0178d 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -52,8 +52,8 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) // Register services
createProtoService(PS_GETAVATARCAPS, &GGPROTO::getavatarcaps);
createProtoService(PS_GETAVATARINFOT, &GGPROTO::getavatarinfo);
- createProtoService(PS_GETMYAVATAR, &GGPROTO::getmyavatar);
- createProtoService(PS_SETMYAVATAR, &GGPROTO::setmyavatar);
+ createProtoService(PS_GETMYAVATART, &GGPROTO::getmyavatar);
+ createProtoService(PS_SETMYAVATART, &GGPROTO::setmyavatar);
createProtoService(PS_GETMYAWAYMSG, &GGPROTO::getmyawaymsg);
createProtoService(PS_CREATEACCMGRUI, &GGPROTO::get_acc_mgr_gui);
@@ -73,12 +73,12 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) TCHAR szPath[MAX_PATH];
TCHAR *tmpPath = Utils_ReplaceVarsT( _T("%miranda_avatarcache%"));
- mir_sntprintf(szPath, MAX_PATH, _T("%s\\%s"), tmpPath, m_szModuleName);
+ mir_sntprintf(szPath, MAX_PATH, _T("%s\\%s"), tmpPath, m_tszUserName);
mir_free(tmpPath);
hAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", szPath);
tmpPath = Utils_ReplaceVarsT( _T("%miranda_userdata%"));
- mir_sntprintf(szPath, MAX_PATH, _T("%s\\%s\\ImageCache"), tmpPath, m_szModuleName);
+ mir_sntprintf(szPath, MAX_PATH, _T("%s\\%s\\ImageCache"), tmpPath, m_tszUserName);
mir_free(tmpPath);
hImagesFolder = FoldersRegisterCustomPathT(m_szModuleName, "Images", szPath);
}
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 0ad225ad06..2567838406 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -683,7 +683,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP TCHAR szFileName[MAX_PATH];
OPENFILENAME ofn = {0};
- gg_img_getfilter(szFilter, sizeof(szFilter));
+ gg_img_getfilter(szFilter, SIZEOF(szFilter));
*szFileName = 0;
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
@@ -849,7 +849,9 @@ int GGPROTO::img_displayasmsg(HANDLE hContact, void *img) ccs.szProtoService = PSR_MESSAGE;
ccs.hContact = hContact;
ccs.lParam = (LPARAM)⪯
- mir_snprintf(image_msg, SIZEOF(image_msg), "[img]%s[/img]", szPath);
+ char* szPathA = mir_t2a(szPath);
+ mir_snprintf(image_msg, SIZEOF(image_msg), "[img]%s[/img]", szPathA);
+ mir_free(szPathA);
pre.timestamp = time(NULL);
pre.szMessage = image_msg;
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM) &ccs);
@@ -1040,7 +1042,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName) }
// Load image from file
else
- dat->hBitmap = (HBITMAP) CallService(MS_IMG_LOAD, (WPARAM) szFileName, 0);
+ dat->hBitmap = (HBITMAP) CallService(MS_IMG_LOAD, (WPARAM) szFileName, IMGL_TCHAR);
// If everything is fine return the handle
if (dat->hBitmap) return dat;
@@ -1147,9 +1149,11 @@ BOOL GGPROTO::img_sendonrequest(gg_event* e) if (!this || !dat || !isonline())
return FALSE;
+ char* lpszFileNameA = mir_t2a(dat->lpImages->lpszFileName);
EnterCriticalSection(&sess_mutex);
- gg_image_reply(sess, e->event.image_request.sender, dat->lpImages->lpszFileName, dat->lpImages->lpData, dat->lpImages->nSize);
+ gg_image_reply(sess, e->event.image_request.sender, lpszFileNameA, dat->lpImages->lpData, dat->lpImages->nSize);
LeaveCriticalSection(&sess_mutex);
+ mir_free(lpszFileNameA);
gg_img_remove(dat);
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp index e4ff066d11..7fcb8b0df8 100644 --- a/protocols/Gadu-Gadu/src/import.cpp +++ b/protocols/Gadu-Gadu/src/import.cpp @@ -393,7 +393,7 @@ INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam) {
TCHAR error[128];
LeaveCriticalSection(&sess_mutex);
- mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be removeed because of error:\n\t%s"), strerror(errno));
+ mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be removeed because of error:\n\t%s"), _tcserror(errno));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
netlog("gg_remove_server(): Cannot remove list because of \"%s\".", strerror(errno));
}
diff --git a/protocols/Gadu-Gadu/src/libgadu/libgadu.h b/protocols/Gadu-Gadu/src/libgadu/libgadu.h index d273d998e1..82214e65ed 100644 --- a/protocols/Gadu-Gadu/src/libgadu/libgadu.h +++ b/protocols/Gadu-Gadu/src/libgadu/libgadu.h @@ -690,7 +690,7 @@ int gg_send_message_ctcp(struct gg_session *sess, int msgclass, uin_t recipient, int gg_ping(struct gg_session *sess); int gg_userlist_request(struct gg_session *sess, char type, const char *request); int gg_image_request(struct gg_session *sess, uin_t recipient, int size, uint32_t crc32); -int gg_image_reply(struct gg_session *sess, uin_t recipient, const TCHAR *filename, const char *image, int size); +int gg_image_reply(struct gg_session *sess, uin_t recipient, const char *filename, const char *image, int size); int gg_typing_notification(struct gg_session *sess, uin_t recipient, int length); uint32_t gg_crc32(uint32_t crc, const unsigned char *buf, int len); diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index c9681c56ef..877cea3f20 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -43,7 +43,7 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail) TCHAR error[128];
mir_sntprintf(error, SIZEOF(error), TranslateT("Cannot register new account because of error:\n\t%S"),
(h && !s) ? http_error_string(h ? h->error : 0) :
- (s ? Translate("Registration rejected") : strerror(errno)));
+ (s ? TranslateT("Registration rejected") : _tcserror(errno)));
MessageBox(
NULL,
error,
@@ -95,7 +95,7 @@ void *gg_dounregister(GGPROTO *gg, uin_t uin, char *password) TCHAR error[128];
mir_sntprintf(error, SIZEOF(error), TranslateT("Your account cannot be removed because of error:\n\t%S"),
(h && !s) ? http_error_string(h ? h->error : 0) :
- (s ? Translate("Bad number or password") : strerror(errno)));
+ (s ? TranslateT("Bad number or password") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
gg->netlog("gg_dounregister(): Cannot remove account because of \"%s\".", strerror(errno));
}
@@ -147,7 +147,7 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass) TCHAR error[128];
mir_sntprintf(error, SIZEOF(error), TranslateT("Your password cannot be changed because of error:\n\t%S"),
(h && !s) ? http_error_string(h ? h->error : 0) :
- (s ? Translate("Invalid data entered") : strerror(errno)));
+ (s ? TranslateT("Invalid data entered") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
gg->netlog("gg_dochpass(): Cannot change password because of \"%s\".", strerror(errno));
}
@@ -189,7 +189,7 @@ void *gg_dochemail(GGPROTO *gg, uin_t uin, char *password, char *email, char *ne {
TCHAR error[128];
mir_sntprintf(error, SIZEOF(error), TranslateT("Your e-mail cannot be changed because of error:\n\t%s"),
- (h && !s) ? http_error_string(h ? h->error : 0) : (s ? Translate("Bad old e-mail or password") : strerror(errno)));
+ (h && !s) ? http_error_string(h ? h->error : 0) : (s ? TranslateT("Bad old e-mail or password") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
gg->netlog("gg_dochpass(): Cannot change e-mail because of \"%s\".", strerror(errno));
}
|