summaryrefslogtreecommitdiff
path: root/protocols/GTalkExt/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/GTalkExt/src')
-rw-r--r--protocols/GTalkExt/src/handlers.cpp3
-rw-r--r--protocols/GTalkExt/src/inbox.cpp2
-rw-r--r--protocols/GTalkExt/src/notifications.cpp20
-rw-r--r--protocols/GTalkExt/src/tipper_items.cpp104
4 files changed, 55 insertions, 74 deletions
diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp
index 0587df041b..aa8f45371e 100644
--- a/protocols/GTalkExt/src/handlers.cpp
+++ b/protocols/GTalkExt/src/handlers.cpp
@@ -312,7 +312,8 @@ BOOL DiscoverHandler(IJabberInterface *ji, HXML node, void *pUserData)
node = xi.getChildByAttrValue(node, NODENAME_QUERY, ATTRNAME_XMLNS, DISCOVERY_XMLNS);
HXML child = xi.getChildByAttrValue(node, NODENAME_FEATURE, ATTRNAME_VAR, SETTING_FEATURE_XMLNS);
- if (child) SetNotificationSetting(jid, ji);
+ if (child)
+ SetNotificationSetting(jid, ji);
child = xi.getChildByAttrValue(node, NODENAME_FEATURE, ATTRNAME_VAR, NOTIFY_FEATURE_XMLNS);
if (child) {
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp
index 4343ae6fe2..9fd82a5aec 100644
--- a/protocols/GTalkExt/src/inbox.cpp
+++ b/protocols/GTalkExt/src/inbox.cpp
@@ -242,7 +242,7 @@ void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url)
void OpenContactInbox(HANDLE hContact)
{
LPSTR acc = GetContactProto(hContact);
- if (!acc)
+ if (acc == NULL)
return;
ptrT tszJid( db_get_tsa(0, acc, "jid"));
diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp
index 373ca1cbba..59743a2a57 100644
--- a/protocols/GTalkExt/src/notifications.cpp
+++ b/protocols/GTalkExt/src/notifications.cpp
@@ -54,17 +54,13 @@ LPCSTR GetJidAcc(LPCTSTR jid)
int count = 0;
PROTOACCOUNT **protos;
ProtoEnumAccounts(&count, &protos);
-
- DBVARIANT dbv;
- for (int i=0; i < count; i++)
- if (getJabberApi(protos[i]->szModuleName))
- if (!db_get_ts(0, protos[i]->szModuleName, "jid", &dbv))
- __try {
- if (!lstrcmpi(jid, dbv.ptszVal)) return protos[i]->szModuleName;
- }
- __finally {
- db_free(&dbv);
- }
+ for (int i=0; i < count; i++) {
+ if ( getJabberApi(protos[i]->szModuleName)) {
+ ptrT tszJid( db_get_tsa(0, protos[i]->szModuleName, "jid"));
+ if ( !lstrcmpi(jid, tszJid))
+ return protos[i]->szModuleName;
+ }
+ }
return NULL;
}
@@ -246,7 +242,7 @@ void ShowNotification(LPCSTR acc, POPUPDATAT *data, LPCTSTR jid, LPCTSTR url, LP
data->PluginWindowProc = PopupProc;
int lurl = (lstrlen(url) + 1) * sizeof(TCHAR);
int ljid = (lstrlen(jid) + 1) * sizeof(TCHAR);
-
+
POPUP_DATA_HEADER *ppdh = (POPUP_DATA_HEADER*)malloc(sizeof(POPUP_DATA_HEADER) + lurl + ljid);
ppdh->MarkRead = FALSE;
ppdh->hContact = hCnt;
diff --git a/protocols/GTalkExt/src/tipper_items.cpp b/protocols/GTalkExt/src/tipper_items.cpp
index d774cc8401..869243e905 100644
--- a/protocols/GTalkExt/src/tipper_items.cpp
+++ b/protocols/GTalkExt/src/tipper_items.cpp
@@ -76,80 +76,64 @@ void SetLabelProp(int index, LPSTR setting)
{
sprintf(setting, LABEL_SETTING_PROP, index); //!!!!!!!!!!!!!!
- DBVARIANT dbv1 = {0};
- if (!db_get_ts(0, TIPPER_ITEMS_MOD_NAME, setting, &dbv1))
- __try {
- DBVARIANT dbv2 = {0};
- if (!db_get_ts(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, &dbv2))
- __try {
- if (!lstrcmp(dbv1.ptszVal, dbv2.ptszVal)) {
- LPTSTR label = TranslateTS(UNREAD_THREADS_LABEL);
- db_set_ts(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label);
- db_set_ts(0, TIPPER_ITEMS_MOD_NAME, setting, label);
- }
- }
- __finally {
- db_free(&dbv2);
- }
- }
- __finally {
- db_free(&dbv1);
- }
+ ptrT tszProp( db_get_tsa(0, TIPPER_ITEMS_MOD_NAME, setting));
+ if (tszProp == NULL)
+ return;
+
+ ptrT tszLastWritten( db_get_tsa(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING));
+ if (tszLastWritten == NULL)
+ return;
+
+ if ( !lstrcmp(tszProp, tszLastWritten)) {
+ LPTSTR label = TranslateTS(UNREAD_THREADS_LABEL);
+ db_set_ts(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label);
+ db_set_ts(0, TIPPER_ITEMS_MOD_NAME, setting, label);
+ }
}
void AddTipperItem()
{
- unsigned short itemCount = db_get_w(0, TIPPER_ITEMS_MOD_NAME,
- TIPPER_ITEM_COUNT_SETTING , unsigned short(-1));
- if (unsigned short(-1) == itemCount) return;
+ WORD itemCount = db_get_w(0, TIPPER_ITEMS_MOD_NAME, TIPPER_ITEM_COUNT_SETTING, WORD(-1));
+ if (itemCount == WORD(-1))
+ return;
int i, l = 0;
for (i = itemCount; i > 0; i /= 10) l++; // var setting path
l += 30; // const setting part
- LPSTR setting = (LPSTR)malloc(l * sizeof(TCHAR));
- __try {
- for (i = 0; i < itemCount; i++) {
- mir_snprintf(setting, l, VALUE_SETTING_PROP, i);
-
- DBVARIANT dbv = {0};
- if (!db_get_ts(0, TIPPER_ITEMS_MOD_NAME, setting, &dbv))
- __try {
- if (!lstrcmp(UNREAD_THREADS_RAW, dbv.ptszVal)) {
- SetLabelProp(i, setting);
- return;
- }
- }
- __finally {
- db_free(&dbv);
- }
+ LPSTR setting = (LPSTR)_alloca(l * sizeof(TCHAR));
+
+ for (i = 0; i < itemCount; i++) {
+ mir_snprintf(setting, l, VALUE_SETTING_PROP, i);
+ ptrT tszSetting( db_get_tsa(0, TIPPER_ITEMS_MOD_NAME, setting));
+ if (tszSetting) {
+ if ( !lstrcmp(UNREAD_THREADS_RAW, tszSetting)) {
+ SetLabelProp(i, setting);
+ return;
+ }
}
+ }
- for (i = 0; i < MAX_TIPPER_ITEM_PROP; i++)
- ShiftTipperSettings(setting, itemCount, TipperItemProps[i]);
+ for (i = 0; i < MAX_TIPPER_ITEM_PROP; i++)
+ ShiftTipperSettings(setting, itemCount, TipperItemProps[i]);
- #define WRITE_TIPPER_PROPS(index, value)\
- mir_snprintf(setting, l, TipperItemProps[##index##], 0);\
- db_set_ts(0, TIPPER_ITEMS_MOD_NAME, setting, ##value##)
- #define WRITE_TIPPER_PROPB(index, value)\
- mir_snprintf(setting, l, TipperItemProps[##index##], 0);\
- db_set_b(0, TIPPER_ITEMS_MOD_NAME, setting, ##value##)
+ #define WRITE_TIPPER_PROPS(index, value)\
+ mir_snprintf(setting, l, TipperItemProps[##index##], 0);\
+ db_set_ts(0, TIPPER_ITEMS_MOD_NAME, setting, ##value##)
+ #define WRITE_TIPPER_PROPB(index, value)\
+ mir_snprintf(setting, l, TipperItemProps[##index##], 0);\
+ db_set_b(0, TIPPER_ITEMS_MOD_NAME, setting, ##value##)
- LPTSTR label = TranslateTS(UNREAD_THREADS_LABEL);
+ LPTSTR label = TranslateTS(UNREAD_THREADS_LABEL);
- db_set_ts(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label);
+ db_set_ts(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label);
- WRITE_TIPPER_PROPS(0, label);
- WRITE_TIPPER_PROPB(1, 0);
- WRITE_TIPPER_PROPB(2, 0);
- WRITE_TIPPER_PROPB(3, 0);
- WRITE_TIPPER_PROPS(4, UNREAD_THREADS_RAW);
- WRITE_TIPPER_PROPB(5, 1);
- }
- __finally {
- free(setting);
- }
+ WRITE_TIPPER_PROPS(0, label);
+ WRITE_TIPPER_PROPB(1, 0);
+ WRITE_TIPPER_PROPB(2, 0);
+ WRITE_TIPPER_PROPB(3, 0);
+ WRITE_TIPPER_PROPS(4, UNREAD_THREADS_RAW);
+ WRITE_TIPPER_PROPB(5, 1);
- db_set_w(0, TIPPER_ITEMS_MOD_NAME,
- TIPPER_ITEM_COUNT_SETTING, itemCount + 1);
+ db_set_w(0, TIPPER_ITEMS_MOD_NAME, TIPPER_ITEM_COUNT_SETTING, itemCount+1);
} \ No newline at end of file