summaryrefslogtreecommitdiff
path: root/protocols/GTalkExt/src/tipper_items.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-25 12:07:46 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-25 12:07:46 +0000
commite64818967374ebdadf6f22d18296e7bc6088277b (patch)
tree14736c4f5d51012dfccb63bc745f08a63ec4f8fd /protocols/GTalkExt/src/tipper_items.cpp
parentdd1460d664f7266920b07527f25f87ec8233daaf (diff)
IsFullScreen(), IsWorkstationLocked(), IsScreenSaverRunning() moved to the core
git-svn-id: http://svn.miranda-ng.org/main/trunk@6226 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/GTalkExt/src/tipper_items.cpp')
-rw-r--r--protocols/GTalkExt/src/tipper_items.cpp104
1 files changed, 44 insertions, 60 deletions
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