summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src/avatar.cpp
diff options
context:
space:
mode:
authorSzymon Tokarz <wsx22@o2.pl>2012-11-29 00:24:59 +0000
committerSzymon Tokarz <wsx22@o2.pl>2012-11-29 00:24:59 +0000
commitd38f5bfee7197b4094d189d95fe6ee004576dc1d (patch)
tree60d2b2b7e8e8186dc98932529be2e4fa3be2189e /protocols/Gadu-Gadu/src/avatar.cpp
parent30707c980d1560b358dbf2671a4d2a26a1e8173c (diff)
Gadu-Gadu protocol: account avatar work
- fixes setting custom avatar (when do it first time or change it to another type) - fixed restoring oryginal avatar when setting new has faild (it's complex mechanism and could need some more work, but i'm hope that this and last commits are enough for now) git-svn-id: http://svn.miranda-ng.org/main/trunk@2553 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu/src/avatar.cpp')
-rw-r--r--protocols/Gadu-Gadu/src/avatar.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp
index c5c889e369..d49b888064 100644
--- a/protocols/Gadu-Gadu/src/avatar.cpp
+++ b/protocols/Gadu-Gadu/src/avatar.cpp
@@ -378,13 +378,17 @@ void __cdecl GGPROTO::setavatarthread(void *param)
char szUrl[128], uin[32], *authHeader, *data, *avatardata, content[256], image_ext[4], image_type[11];
int file_fd, avatardatalen, datalen, contentlen, contentendlen, res = 0, repeat = 0;
- netlog("setavatarthread(): started. Trying to set user avatar using %s...", szFilename);
+ netlog("setavatarthread(): started. Trying to set user avatar.");
UIN2ID( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
file_fd = _topen(szFilename, _O_RDONLY | _O_BINARY, _S_IREAD);
if (file_fd == -1) {
netlog("setavatarthread(): Failed to open avatar file (%s).", strerror(errno));
mir_free(szFilename);
+ int prevType = db_get_b(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV, -1);
+ if (prevType != -1)
+ db_set_b(NULL, m_szModuleName, GG_KEY_AVATARTYPE, prevType);
+ db_unset(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV);
getUserAvatar();
#ifdef DEBUGMODE
netlog("setavatarthread(): end. err1");
@@ -492,10 +496,15 @@ void __cdecl GGPROTO::setavatarthread(void *param)
mir_free(avatardata);
mir_free(data);
- if (res)
+ if (res) {
netlog("setavatarthread(): User avatar set successfully.");
- else
+ } else {
+ int prevType = db_get_b(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV, -1);
+ if (prevType != -1)
+ db_set_b(NULL, m_szModuleName, GG_KEY_AVATARTYPE, prevType);
netlog("setavatarthread(): Failed to set user avatar.");
+ }
+ db_unset(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV);
mir_free(szFilename);
getUserAvatar();
@@ -507,7 +516,7 @@ void __cdecl GGPROTO::setavatarthread(void *param)
void GGPROTO::setAvatar(const TCHAR *szFilename)
{
#ifdef DEBUGMODE
- netlog("setAvatar(): forkthread 3 GGPROTO::setavatarthread");
+ netlog("setAvatar(): forkthread 3 GGPROTO::setavatarthread");
#endif
forkthread(&GGPROTO::setavatarthread, mir_tstrdup(szFilename));
}