summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp124
-rw-r--r--protocols/Gadu-Gadu/src/dialogs.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/gg.h6
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.h16
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp120
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp18
7 files changed, 180 insertions, 110 deletions
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp
index acd2d89b74..607f67533b 100644
--- a/protocols/Gadu-Gadu/src/core.cpp
+++ b/protocols/Gadu-Gadu/src/core.cpp
@@ -683,13 +683,17 @@ retry:
|| res->seq == GG_SEQ_CHINFO)
{
// Change nickname if it's not present
- if (__nick && (res->seq == GG_SEQ_GETNICK || res->seq == GG_SEQ_CHINFO))
- db_set_s(hContact, m_szModuleName, GG_KEY_NICK, __nick);
+ if (__nick && (res->seq == GG_SEQ_GETNICK || res->seq == GG_SEQ_CHINFO)){
+ TCHAR* __nickT = mir_a2t(__nick);
+ db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, __nickT);
+ mir_free(__nickT);
+ }
- if (__nick)
+ if (__nick){
db_set_s(hContact, m_szModuleName, "NickName", __nick);
- else if (res->seq == GG_SEQ_CHINFO)
+ } else if (res->seq == GG_SEQ_CHINFO) {
db_unset(NULL, m_szModuleName, "NickName");
+ }
// Change other info
if (__city)
@@ -821,23 +825,26 @@ retry:
// Check if groupchat
if (e->event.msg.recipients_count && gc_enabled && !db_get_b(NULL, m_szModuleName, GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF))
{
- char *chat = gc_getchat(e->event.msg.sender, e->event.msg.recipients, e->event.msg.recipients_count);
+ TCHAR *chat = gc_getchat(e->event.msg.sender, e->event.msg.recipients, e->event.msg.recipients_count);
if (chat)
{
- char id[32];
- GCDEST gcdest = {m_szModuleName, chat, GC_EVENT_MESSAGE};
+ TCHAR id[32];
+ GCDEST gcdest = {0};
+ gcdest.pszModule = m_szModuleName;
+ gcdest.ptszID = chat;
+ gcdest.iType = GC_EVENT_MESSAGE;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
time_t t = time(NULL);
- UIN2ID(e->event.msg.sender, id);
+ UIN2IDT(e->event.msg.sender, id);
- gcevent.pszUID = id;
+ gcevent.ptszUID = id;
TCHAR* messageT = mir_a2t(e->event.msg.message);
gcevent.ptszText = messageT;
gcevent.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR);
gcevent.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- netlog("mainthread() (%x): Conference message to room %s & id %s.", this, chat, id);
+ netlog("mainthread() (%x): Conference message to room %S & id %S.", this, chat, id);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
mir_free(messageT);
}
@@ -886,34 +893,37 @@ retry:
case GG_EVENT_MULTILOGON_MSG:
if (e->event.multilogon_msg.recipients_count && gc_enabled && !db_get_b(NULL, m_szModuleName, GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF))
{
- char *chat = gc_getchat(e->event.multilogon_msg.sender, e->event.multilogon_msg.recipients, e->event.multilogon_msg.recipients_count);
+ TCHAR *chat = gc_getchat(e->event.multilogon_msg.sender, e->event.multilogon_msg.recipients, e->event.multilogon_msg.recipients_count);
if (chat)
{
- char id[32];
+ TCHAR id[32];
DBVARIANT dbv;
- GCDEST gcdest = {m_szModuleName, chat, GC_EVENT_MESSAGE};
+ GCDEST gcdest = {0};
+ gcdest.pszModule = m_szModuleName;
+ gcdest.ptszID = chat;
+ gcdest.iType = GC_EVENT_MESSAGE;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- UIN2ID( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), id);
+ UIN2IDT(db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), id);
- gcevent.pszUID = id;
+ gcevent.ptszUID = id;
TCHAR* messageT = mir_a2t(e->event.multilogon_msg.message);
gcevent.ptszText = messageT;
- TCHAR* pszValT;
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ)){
- pszValT = mir_a2t(dbv.pszVal);
- gcevent.ptszNick = pszValT;
+ TCHAR* nickT;
+ if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR)){
+ nickT = mir_tstrdup(dbv.ptszVal);
DBFreeVariant(&dbv);
} else {
- gcevent.ptszNick = TranslateT("Me");
+ nickT = mir_tstrdup(TranslateT("Me"));
}
+ gcevent.ptszNick = nickT;
gcevent.time = e->event.multilogon_msg.time;
gcevent.bIsMe = 1;
gcevent.dwFlags = GCEF_ADDTOLOG;
- netlog("mainthread() (%x): Sent conference message to room %s.", this, chat);
+ netlog("mainthread() (%x): Sent conference message to room %S.", this, chat);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
mir_free(messageT);
- if (pszValT != NULL) mir_free(pszValT);;
+ mir_free(nickT);
}
}
else if (!e->event.multilogon_msg.recipients_count && e->event.multilogon_msg.message && *e->event.multilogon_msg.message
@@ -1282,11 +1292,15 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam)
type = db_get_b(hContact, m_szModuleName, "ChatRoom", 0);
// Terminate conference if contact is deleted
- if (type && !db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_ASCIIZ) && gc_enabled)
+ if (type && !db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR) && gc_enabled)
{
- GCDEST gcdest = {m_szModuleName, dbv.pszVal, GC_EVENT_CONTROL};
+
+ GCDEST gcdest = {0};
+ gcdest.pszModule = m_szModuleName;
+ gcdest.ptszID = dbv.ptszVal;
+ gcdest.iType = GC_EVENT_CONTROL;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- GGGC *chat = gc_lookup(dbv.pszVal);
+ GGGC *chat = gc_lookup(dbv.ptszVal);
netlog("contactdeleted(): Terminating chat %x, id %s from contact list...", chat, dbv.pszVal);
if (chat)
@@ -1316,6 +1330,19 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam)
////////////////////////////////////////////////////////////
// When db settings changed
+static TCHAR* sttSettingToTchar( DBVARIANT* value )
+{
+ switch(value->type) {
+ case DBVT_ASCIIZ:
+ return mir_a2t(value->pszVal);
+ case DBVT_UTF8:
+ return mir_utf8decodeT(value->pszVal);
+ case DBVT_WCHAR:
+ return mir_u2t(value->pwszVal);
+ }
+ return NULL;
+}
+
int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam)
{
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
@@ -1336,40 +1363,51 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam)
}
// Contact is being renamed
- if (gc_enabled && !strcmp(cws->szModule, m_szModuleName) && !strcmp(cws->szSetting, GG_KEY_NICK)
- && cws->value.pszVal)
- {
+ if (gc_enabled && !strcmp(cws->szModule, m_szModuleName) && !strcmp(cws->szSetting, GG_KEY_NICK)){
+
+ TCHAR* ptszVal = sttSettingToTchar(&(cws->value));
+ if(ptszVal==NULL) return 0;
+
// Groupchat window contact is being renamed
DBVARIANT dbv;
int type = db_get_b(hContact, m_szModuleName, "ChatRoom", 0);
- if (type && !db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_ASCIIZ))
+ if (type && !db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR))
{
// Most important... check redundancy (fucking cascading)
static int cascade = 0;
- if (!cascade && dbv.pszVal)
+ if (!cascade && dbv.ptszVal)
{
- GCDEST gcdest = {m_szModuleName, dbv.pszVal, GC_EVENT_CHANGESESSIONAME};
+ GCDEST gcdest = {0};
+ gcdest.pszModule = m_szModuleName;
+ gcdest.ptszID = dbv.ptszVal;
+ gcdest.iType = GC_EVENT_CHANGESESSIONAME;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- gcevent.pszText = cws->value.pszVal;
- netlog("dbsettingchanged(): Conference %s was renamed to %s.", dbv.pszVal, cws->value.pszVal);
+ gcevent.dwFlags = GC_TCHAR;
+ gcevent.ptszText = ptszVal;
+ netlog("dbsettingchanged(): Conference %s was renamed.", dbv.pszVal);
// Mark cascading
/* FIXME */ cascade = 1;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
/* FIXME */ cascade = 0;
}
DBFreeVariant(&dbv);
- }
- else
+ } else {
// Change contact name on all chats
- gc_changenick(hContact, cws->value.pszVal);
+ gc_changenick(hContact, ptszVal);
+ }
+ mir_free(ptszVal);
}
// Contact list changes
if (!strcmp(cws->szModule, "CList"))
{
// If name changed... change nick
- if (!strcmp(cws->szSetting, "MyHandle") && cws->value.type == DBVT_ASCIIZ && cws->value.pszVal)
- db_set_s(hContact, m_szModuleName, GG_KEY_NICK, cws->value.pszVal);
+ if (!strcmp(cws->szSetting, "MyHandle")){
+ TCHAR* ptszVal = sttSettingToTchar(&(cws->value));
+ if(ptszVal==NULL) return 0;
+ db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, ptszVal);
+ mir_free(ptszVal);
+ }
// If not on list changed
if (!strcmp(cws->szSetting, "NotOnList"))
@@ -1552,7 +1590,7 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick)
hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
if (!hContact) {
- netlog("getcontact(): Failed to create Gadu-Gadu contact %s", szNick);
+ netlog("getcontact(): Failed to create Gadu-Gadu contact %S", szNick);
return NULL;
}
@@ -1572,9 +1610,7 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick)
// If nick specified use it
if (szNick) {
- char* szNickA = mir_t2a(szNick);
- db_set_s(hContact, m_szModuleName, GG_KEY_NICK, szNickA);
- mir_free(szNickA);
+ db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, szNick);
} else if (isonline()) {
gg_pubdir50_t req;
@@ -1587,7 +1623,9 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick)
gg_pubdir50(sess, req);
gg_LeaveCriticalSection(&sess_mutex, "getcontact", 31, 1, "sess_mutex", 1);
gg_pubdir50_free(req);
- db_set_s(hContact, m_szModuleName, GG_KEY_NICK, ditoa(uin));
+ TCHAR* uinT = mir_a2t(ditoa(uin));
+ db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, uinT);
+ mir_free(uinT);
netlog("getcontact(): Search for nick on uin: %d", uin);
}
}
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp
index 440e0718e4..1e194f0951 100644
--- a/protocols/Gadu-Gadu/src/dialogs.cpp
+++ b/protocols/Gadu-Gadu/src/dialogs.cpp
@@ -133,11 +133,11 @@ int GGPROTO::options_init(WPARAM wParam, LPARAM lParam)
odp.ptszGroup = LPGENT("Network");
odp.ptszTitle = m_tszUserName;
odp.dwInitParam = (LPARAM)this;
+ odp.flags = ODPF_TCHAR | ODPF_BOLDGROUPS | ODPF_DONTTRANSLATE;
odp.ptszTab = LPGENT("General");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_GG_GENERAL);
odp.pfnDlgProc = gg_genoptsdlgproc;
- odp.flags = ODPF_TCHAR | ODPF_BOLDGROUPS | ODPF_DONTTRANSLATE;
Options_AddPage(wParam, &odp);
odp.ptszTab = LPGENT("Conference");
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h
index 64cb806ff5..0885779876 100644
--- a/protocols/Gadu-Gadu/src/gg.h
+++ b/protocols/Gadu-Gadu/src/gg.h
@@ -119,7 +119,7 @@ typedef struct
{
uin_t *recipients;
int recipients_count;
- char id[32];
+ TCHAR id[32];
BOOL ignore;
} GGGC;
@@ -329,7 +329,9 @@ void gg_links_instancemenu_init();
void gg_links_init();
void gg_links_destroy();
-#define UIN2ID(uin,id) _itoa(uin,id,10)
+#define UIN2ID(uin,id) _itoa(uin,id,10) //@deprecated
+#define UIN2IDA(uin,id) _itoa(uin,id,10)
+#define UIN2IDT(uin,id) _itot(uin,id,10)
// Debug functions
const char *ggdebug_eventtype(gg_event *e);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index 8911110ccf..ced5f83cd5 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -23,6 +23,10 @@
GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName)
{
+#ifdef DEBUGMODE
+ extendedLogging = 0;
+#endif
+
// Init mutexes
InitializeCriticalSection(&sess_mutex);
InitializeCriticalSection(&ft_mutex);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h
index e1be4c2cff..10ca4efafa 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.h
+++ b/protocols/Gadu-Gadu/src/gg_proto.h
@@ -111,6 +111,9 @@ struct GGPROTO : public PROTO_INTERFACE, public MZeroedObject
HANDLE forkthreadex(GGThreadFunc pFunc, void *param, UINT *threadId);
void threadwait(GGTHREAD *thread);
+#ifdef DEBUGMODE
+ volatile int extendedLogging;
+#endif
void gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, char* mutexName, int logging);
void gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, int returnNumber, char* mutexName, int logging);
void gg_sleep(DWORD miliseconds, BOOL alterable, char* callingFunction, int sleepNumber, int logging);
@@ -217,9 +220,9 @@ struct GGPROTO : public PROTO_INTERFACE, public MZeroedObject
int gc_init();
void gc_menus_init(HGENMENU hRoot);
int gc_destroy();
- char * gc_getchat(uin_t sender, uin_t *recipients, int recipients_count);
- GGGC *gc_lookup(char *id);
- int gc_changenick(HANDLE hContact, char *pszNick);
+ TCHAR * gc_getchat(uin_t sender, uin_t *recipients, int recipients_count);
+ GGGC *gc_lookup(TCHAR *id);
+ int gc_changenick(HANDLE hContact, TCHAR *ptszNick);
#define UIN2ID(uin,id) _itoa(uin,id,10)
int __cdecl gc_event(WPARAM wParam, LPARAM lParam);
@@ -301,6 +304,7 @@ inline void GGPROTO::gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char* call
{
#ifdef DEBUGMODE
int logAfter = 0;
+ extendedLogging = 1;
if(logging == 1 && mutex->LockCount != -1) {
logAfter = 1;
netlog("%s(): %i before EnterCriticalSection %s LockCount=%ld RecursionCount=%ld OwningThread=%ld", callingFunction, sectionNumber, mutexName, mutex->LockCount, mutex->RecursionCount, mutex->OwningThread);
@@ -309,13 +313,15 @@ inline void GGPROTO::gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char* call
EnterCriticalSection(mutex);
#ifdef DEBUGMODE
if(logging == 1 && logAfter == 1) netlog("%s(): %i after EnterCriticalSection %s LockCount=%ld RecursionCount=%ld OwningThread=%ld", callingFunction, sectionNumber, mutexName, mutex->LockCount, mutex->RecursionCount, mutex->OwningThread);
+ extendedLogging = 0;
#endif
+
}
inline void GGPROTO::gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, int returnNumber, char* mutexName, int logging) /*0-never, 1-debug, 2-all*/
{
#ifdef DEBUGMODE
- if(logging == 1) netlog("%s(): %i.%i LeaveCriticalSection %s", callingFunction, sectionNumber, returnNumber, mutexName);
+ if(logging == 1 && extendedLogging == 1) netlog("%s(): %i.%i LeaveCriticalSection %s", callingFunction, sectionNumber, returnNumber, mutexName);
#endif
LeaveCriticalSection(mutex);
}
@@ -323,7 +329,7 @@ inline void GGPROTO::gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char* call
inline void GGPROTO::gg_sleep(DWORD miliseconds, BOOL alterable, char* callingFunction, int sleepNumber, int logging){
SleepEx(miliseconds, alterable);
#ifdef DEBUGMODE
- if(logging == 1) netlog("%s(): %i after SleepEx(%ld,%u)", callingFunction, sleepNumber, miliseconds, alterable);
+ if(logging == 1 && extendedLogging == 1) netlog("%s(): %i after SleepEx(%ld,%u)", callingFunction, sleepNumber, miliseconds, alterable);
#endif
}
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index c9e56fc777..48ab50ca81 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -103,7 +103,7 @@ int GGPROTO::gc_destroy()
return 1;
}
-GGGC* GGPROTO::gc_lookup(char *id)
+GGGC* GGPROTO::gc_lookup(TCHAR *id)
{
GGGC *chat;
list_t l;
@@ -111,7 +111,7 @@ GGGC* GGPROTO::gc_lookup(char *id)
for(l = chats; l; l = l->next)
{
chat = (GGGC *)l->data;
- if (chat && !strcmp(chat->id, id))
+ if (chat && !_tcscmp(chat->id, id))
return chat;
}
@@ -127,18 +127,18 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
// Check if we got our protocol, and fields are set
if (!gch
|| !gch->pDest
- || !gch->pDest->pszID
+ || !gch->pDest->ptszID
|| !gch->pDest->pszModule
|| lstrcmpiA(gch->pDest->pszModule, m_szModuleName)
|| !(uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0))
- || !(chat = gc_lookup(gch->pDest->pszID)))
+ || !(chat = gc_lookup(gch->pDest->ptszID)))
return 0;
- // Window terminated
+ // Window terminated (Miranda exit)
if (gch->pDest->iType == SESSION_TERMINATE)
{
HANDLE hContact = NULL;
- netlog("gc_event(): Terminating chat %x, id %s from chat window...", chat, gch->pDest->pszID);
+ netlog("gc_event(): Terminating chat %x, id %S from chat window...", chat, gch->pDest->ptszID);
// Destroy chat entry
free(chat->recipients);
list_remove(&chats, chat, 1);
@@ -147,9 +147,9 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
while (hContact)
{
DBVARIANT dbv;
- if (!db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_ASCIIZ))
+ if (!db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR))
{
- if (dbv.pszVal && !strcmp(gch->pDest->pszID, dbv.pszVal))
+ if (dbv.ptszVal && !_tcscmp(gch->pDest->ptszID, dbv.ptszVal))
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
DBFreeVariant(&dbv);
}
@@ -161,24 +161,27 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
// Message typed / send only if online
if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->ptszText)
{
- char id[32];
+ TCHAR id[32];
DBVARIANT dbv;
- GCDEST gcdest = {m_szModuleName, gch->pDest->pszID, GC_EVENT_MESSAGE};
+ GCDEST gcdest = {0};
+ gcdest.pszModule = m_szModuleName;
+ gcdest.ptszID = gch->pDest->ptszID;
+ gcdest.iType = GC_EVENT_MESSAGE;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
int lc;
- UIN2ID(uin, id);
+ UIN2IDT(uin, id);
- gcevent.pszUID = id;
+ gcevent.ptszUID = id;
gcevent.ptszText = gch->ptszText;
- TCHAR* pszValT;
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ)){
- pszValT = mir_a2t(dbv.pszVal);
- gcevent.ptszNick = pszValT;
+ TCHAR* nickT;
+ if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR)){
+ nickT = mir_tstrdup(dbv.ptszVal);
DBFreeVariant(&dbv);
} else {
- gcevent.ptszNick = TranslateT("Me");
+ nickT = mir_tstrdup(TranslateT("Me"));
}
+ gcevent.ptszNick = nickT;
// Get rid of CRLF at back
lc = (int)_tcslen(gch->ptszText) - 1;
@@ -188,9 +191,9 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
gcevent.time = time(NULL);
gcevent.bIsMe = 1;
gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- netlog("gc_event(): Sending conference message to room %s, \"%s\".", gch->pDest->pszID, pszText);
+ netlog("gc_event(): Sending conference message to room %S, \"%s\".", gch->pDest->ptszID, pszText);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
- if (pszValT != NULL) mir_free(pszValT);;
+ mir_free(nickT);
gg_EnterCriticalSection(&sess_mutex, "gc_event", 57, "sess_mutex", 1);
gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, (BYTE*)pszText);
@@ -204,7 +207,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
if (gch->pDest->iType == GC_USER_PRIVMESS)
{
HANDLE hContact = NULL;
- if ((uin = atoi(gch->pszUID)) && (hContact = getcontact(uin, 1, 0, NULL)))
+ if ((uin = _ttoi(gch->ptszUID)) && (hContact = getcontact(uin, 1, 0, NULL)))
CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
}
char* pszText = mir_t2a(gch->ptszText);
@@ -225,11 +228,11 @@ typedef struct _gg_gc_echat
////////////////////////////////////////////////////////////////////////////////
// This is main groupchat initialization routine
-char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
+TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
{
list_t l; int i;
GGGC *chat;
- char id[32];
+ TCHAR id[32];
uin_t uin; DBVARIANT dbv;
GCDEST gcdest = {m_szModuleName, 0, GC_EVENT_ADDGROUP};
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
@@ -260,9 +263,9 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
if (found == recipients_count)
{
if (chat->ignore)
- netlog("gc_getchat(): Ignoring existing id %s, size %d.", chat->id, chat->recipients_count);
+ netlog("gc_getchat(): Ignoring existing id %S, size %d.", chat->id, chat->recipients_count);
else
- netlog("gc_getchat(): Returning existing id %s, size %d.", chat->id, chat->recipients_count);
+ netlog("gc_getchat(): Returning existing id %S, size %d.", chat->id, chat->recipients_count);
return !(chat->ignore) ? chat->id : NULL;
}
}
@@ -270,7 +273,8 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
// Make new uin list to chat mapping
chat = (GGGC *)malloc(sizeof(GGGC));
- UIN2ID(gc_id ++, chat->id); chat->ignore = FALSE;
+ UIN2IDT(gc_id ++, chat->id);
+ chat->ignore = FALSE;
// Check groupchat policy (new) / only for incoming
if (sender)
@@ -307,7 +311,7 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
for(i = 0; i < recipients_count; i++)
chat->recipients[i] = recipients[i];
if (sender) chat->recipients[i] = sender;
- netlog("gc_getchat(): Ignoring new chat %s, count %d.", chat->id, chat->recipients_count);
+ netlog("gc_getchat(): Ignoring new chat %S, count %d.", chat->id, chat->recipients_count);
list_add(&chats, chat, 0);
return NULL;
}
@@ -318,12 +322,13 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
TCHAR *senderName = sender ? pcli->pfnGetContactDisplayName(getcontact(sender, 1, 0, NULL), 0) : NULL;
mir_sntprintf(status, 255, (sender) ? TranslateT("%s initiated the conference.") : TranslateT("This is my own conference."), senderName);
GCSESSION gcwindow = { 0 };
- gcwindow.cbSize = sizeof(GCSESSION);
- gcwindow.iType = GCW_CHATROOM;
+ gcwindow.cbSize = sizeof(GCSESSION);
+ gcwindow.iType = GCW_CHATROOM;
+ gcwindow.dwFlags = GC_TCHAR;
gcwindow.pszModule = m_szModuleName;
- gcwindow.ptszName = sender ? senderName : TranslateT("Conference");
- gcwindow.pszID = chat->id;
- gcwindow.dwFlags = GC_TCHAR;
+ gcwindow.ptszName = sender ? senderName : TranslateT("Conference");
+ gcwindow.ptszID = chat->id;
+ gcwindow.dwFlags = GC_TCHAR;
gcwindow.dwItemData = (DWORD)chat;
gcwindow.ptszStatusbarText = status;
@@ -334,15 +339,15 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
// Create new room
if (CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM) &gcwindow))
{
- netlog("gc_getchat(): Cannot create new chat window %s.", chat->id);
+ netlog("gc_getchat(): Cannot create new chat window %S.", chat->id);
free(name);
free(chat);
return NULL;
}
free(name);
- gcdest.pszID = chat->id;
- gcevent.pszUID = id;
+ gcdest.ptszID = chat->id;
+ gcevent.ptszUID = id;
gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
gcevent.time = 0;
@@ -354,15 +359,21 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
// Add myself
if (uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0))
{
- UIN2ID(uin, id);
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ)) {
- gcevent.ptszNick = mir_a2t(dbv.pszVal);
+ UIN2IDT(uin, id);
+
+ TCHAR* nickT;
+ if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR)) {
+ nickT = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
+ } else {
+ nickT = mir_tstrdup(TranslateT("Me"));
}
- else gcevent.ptszNick = TranslateT("Me");
+ gcevent.ptszNick = nickT;
+
gcevent.bIsMe = 1;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
- netlog("gc_getchat(): Myself %s: %S (%S) to the list...", gcevent.pszUID, gcevent.ptszNick, gcevent.ptszStatus);
+ mir_free(nickT);
+ netlog("gc_getchat(): Myself %S: %S (%S) to the list...", gcevent.ptszUID, gcevent.ptszNick, gcevent.ptszStatus);
}
else netlog("gc_getchat(): Myself adding failed with uin %d !!!", uin);
@@ -376,14 +387,14 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count)
// Add contacts
for(i = 0; i < chat->recipients_count; i++) {
HANDLE hContact = getcontact(chat->recipients[i], 1, 0, NULL);
- UIN2ID(chat->recipients[i], id);
+ UIN2IDT(chat->recipients[i], id);
if (hContact && (name = pcli->pfnGetContactDisplayName(hContact, 0)) != NULL)
gcevent.ptszNick = name;
else
gcevent.ptszNick = TranslateT("'Unknown'");
gcevent.bIsMe = 0;
gcevent.dwFlags = GC_TCHAR;
- netlog("gc_getchat(): Added %s: %S (%S) to the list...", gcevent.pszUID, gcevent.ptszNick, gcevent.pszStatus);
+ netlog("gc_getchat(): Added %S: %S (%S) to the list...", gcevent.ptszUID, gcevent.ptszNick, gcevent.pszStatus);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
}
gcdest.iType = GC_EVENT_CONTROL;
@@ -483,7 +494,7 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
else if (hwndList && (count = gg_gc_countcheckmarks(hwndList)) >= 2)
{
// Create new participiants table
- char* chat;
+ TCHAR* chat;
uin_t* participants = (uin_t*)calloc(count, sizeof(uin_t));
HANDLE hItem, hContact = db_find_first();
gg->netlog("gg_gc_openconfdlg(): WM_COMMAND IDOK Opening new conference for %d contacts.", count);
@@ -501,7 +512,10 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
chat = gg->gc_getchat(0, participants, count);
if (chat)
{
- GCDEST gcdest = {gg->m_szModuleName, chat, GC_EVENT_CONTROL};
+ GCDEST gcdest = {0};
+ gcdest.pszModule = gg->m_szModuleName;
+ gcdest.ptszID = chat;
+ gcdest.iType = GC_EVENT_CONTROL;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gcevent);
}
@@ -641,13 +655,13 @@ INT_PTR GGPROTO::gc_openconf(WPARAM wParam, LPARAM lParam)
return 1;
}
-int GGPROTO::gc_changenick(HANDLE hContact, char *pszNick)
+int GGPROTO::gc_changenick(HANDLE hContact, TCHAR *ptszNick)
{
list_t l;
uin_t uin = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
- if (!uin || !pszNick) return 0;
+ if (!uin || !ptszNick) return 0;
- netlog("gc_changenick(): Nickname for uin %d changed to %s.", uin, pszNick);
+ netlog("gc_changenick(): Nickname for uin %d changed. Lookup for chats having this nick", uin);
// Lookup for chats having this nick
for(l = chats; l; l = l->next) {
GGGC *chat = (GGGC *)l->data;
@@ -656,18 +670,20 @@ int GGPROTO::gc_changenick(HANDLE hContact, char *pszNick)
// Rename this window if it's exising in the chat
if (chat->recipients[i] == uin)
{
- char id[32];
+ TCHAR id[32];
GCEVENT gce = {sizeof(GCEVENT)};
GCDEST gcd;
- UIN2ID(uin, id);
+ UIN2IDT(uin, id);
gcd.iType = GC_EVENT_NICK;
gcd.pszModule = m_szModuleName;
gce.pDest = &gcd;
- gcd.pszID = chat->id;
- gce.pszUID = id;
- gce.pszText = pszNick;
- netlog("gc_changenick(): Found room %s with uin %d, sending nick change %s.", chat->id, uin, id);
+ gcd.ptszID = chat->id;
+ gce.ptszUID = id;
+ gce.dwFlags = GC_TCHAR;
+ gce.ptszText = ptszNick;
+
+ netlog("gc_changenick(): Found room %S with uin %d, sending nick change %s.", chat->id, uin, id);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
break;
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 7fd3d73b59..6de84ca6ff 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -125,18 +125,20 @@ char *gg_makecontacts(GGPROTO *gg, int cr)
string_append_c(s, ';');
// Readup Nick
- if (!db_get_s(hContact, "CList", "MyHandle", &dbv, DBVT_ASCIIZ) || !db_get_s(hContact, gg->m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ))
+ if (!db_get_s(hContact, "CList", "MyHandle", &dbv, DBVT_TCHAR) || !db_get_s(hContact, gg->m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR))
{
+ char* dbvA = mir_t2a(dbv.ptszVal);
DBVARIANT dbv2;
if (!db_get_s(hContact, gg->m_szModuleName, "NickName", &dbv2, DBVT_ASCIIZ))
{
string_append(s, dbv2.pszVal);
DBFreeVariant(&dbv2);
+ } else {
+ string_append(s, dbvA);
}
- else
- string_append(s, dbv.pszVal);
string_append_c(s, ';');
- string_append(s, dbv.pszVal);
+ string_append(s, dbvA);
+ mir_free(dbvA);
DBFreeVariant(&dbv);
}
else
@@ -438,6 +440,8 @@ INT_PTR GGPROTO::import_text(WPARAM wParam, LPARAM lParam)
return 0;
*pfilter = '\0';
+ *str = _T('\0');
+
ofn.lpstrFilter = filter;
ofn.lpstrFile = str;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
@@ -481,8 +485,8 @@ INT_PTR GGPROTO::export_text(WPARAM wParam, LPARAM lParam)
TCHAR filter[512], *pfilter;
FILE *f;
- _tcsncpy(str, TranslateT("contacts"), sizeof(str));
- _tcsncat(str, _T(".txt"), sizeof(str) - _tcslen(str));
+ _tcsncpy(str, TranslateT("contacts"), SIZEOF(str));
+ _tcsncat(str, _T(".txt"), SIZEOF(str) - _tcslen(str));
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
_tcsncpy(filter, TranslateT("Text files"), SIZEOF(filter));
@@ -512,7 +516,7 @@ INT_PTR GGPROTO::export_text(WPARAM wParam, LPARAM lParam)
ofn.lpstrDefExt = _T("txt");
#ifdef DEBUGMODE
- netlog("export_text(%s).", str);
+ netlog("export_text(%S).", str);
#endif
if (!GetSaveFileName(&ofn)) return 0;