From 25221b7d2afb70f82eb3805330fd39a6f6708049 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 26 Jun 2012 23:41:55 +0000 Subject: mk: removed all LIST_INTERFACE, MI_INTERFACE & UTF8_INTERFACE instances. all related functions moved to mir_core. git-svn-id: http://svn.miranda-ng.org/main/trunk@644 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewXstatusNotify/common.h | 4 +- plugins/NewXstatusNotify/main.cpp | 192 ++++++++++++++++------------------ plugins/NewXstatusNotify/options.cpp | 196 ++++++++++++++++------------------- 3 files changed, 180 insertions(+), 212 deletions(-) (limited to 'plugins/NewXstatusNotify') diff --git a/plugins/NewXstatusNotify/common.h b/plugins/NewXstatusNotify/common.h index 3cbb588379..343ee4fe58 100644 --- a/plugins/NewXstatusNotify/common.h +++ b/plugins/NewXstatusNotify/common.h @@ -106,8 +106,6 @@ #define JS_PARSE_XMPP_URI "/ParseXmppURI" -extern LIST_INTERFACE li; - typedef struct tagSTATUS { int ID; @@ -123,7 +121,7 @@ typedef struct tagSTATUS COLORREF colorText; } STATUS; -typedef struct tagPLUGINDATA +typedef struct tagPLUGINDATA { WORD newStatus; WORD oldStatus; diff --git a/plugins/NewXstatusNotify/main.cpp b/plugins/NewXstatusNotify/main.cpp index e2eef82117..2d336b291e 100644 --- a/plugins/NewXstatusNotify/main.cpp +++ b/plugins/NewXstatusNotify/main.cpp @@ -30,10 +30,6 @@ HINSTANCE hInst; PLUGINLINK *pluginLink; -MM_INTERFACE mmi = {0}; -UTF8_INTERFACE utfi = {0}; -LIST_INTERFACE li = {0}; - LIST eventList( 10 ); LIST xstatusList( 10 ); @@ -86,7 +82,7 @@ BYTE GetGender(HANDLE hContact) char *szProto =(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (szProto) { - switch (DBGetContactSettingByte(hContact, szProto, "Gender", 0)) + switch (DBGetContactSettingByte(hContact, szProto, "Gender", 0)) { case 'M': case 'm': return GENDER_MALE; @@ -171,17 +167,17 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) if (strstr(cws->szSetting, "/mood/")) { - type = TYPE_JABBER_MOOD; + type = TYPE_JABBER_MOOD; szSetting = "LastJabberMood"; } else { - type = TYPE_JABBER_ACTIVITY; + type = TYPE_JABBER_ACTIVITY; szSetting = "LastJabberActivity"; } - if (strstr(cws->szSetting, "title")) - { + if (strstr(cws->szSetting, "title")) + { TCHAR *stzValue = db2t(&cws->value); if (stzValue) { @@ -201,7 +197,7 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) } AddXSC(xsc); - if (xsc != NULL) + if (xsc != NULL) { ExtraStatusChanged(xsc); FreeXSC(xsc); @@ -218,8 +214,8 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) else xsc = NewXSC(hContact, szProto, type, NOTIFY_NEW_MESSAGE, NULL, stzValue); } - - if (xsc != NULL) + + if (xsc != NULL) { ExtraStatusChanged(xsc); FreeXSC(xsc); @@ -255,7 +251,7 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) } AddXSC(xsc); - if (xsc != NULL) + if (xsc != NULL) { ExtraStatusChanged(xsc); FreeXSC(xsc); @@ -268,7 +264,7 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) TCHAR *stzValue = db2t(&cws->value); xsc = FindXSC(hContact); - if (xsc) + if (xsc) { if (xsc->action == NOTIFY_NEW_XSTATUS) xsc->stzText = stzValue; @@ -278,7 +274,7 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, NOTIFY_NEW_MESSAGE, NULL, stzValue); AddXSC(xsc); } - if (xsc != NULL) + if (xsc != NULL) { ExtraStatusChanged(xsc); FreeXSC(xsc); @@ -417,7 +413,7 @@ static int CompareStatusMsg(STATUSMSGINFO *smi, DBCONTACTWRITESETTING *cws_new) return ret; } -BOOL FreeSmiStr(STATUSMSGINFO *smi) +BOOL FreeSmiStr(STATUSMSGINFO *smi) { mir_free(smi->newstatusmsg); mir_free(smi->oldstatusmsg); @@ -455,7 +451,7 @@ TCHAR* AddCR(const TCHAR *statusmsg) { if(lstrlen(tmp) + len - i + 1 < 1024){ tmp = lstrcat(tmp, statusmsg + i); } - + return tmp; } @@ -482,7 +478,7 @@ TCHAR* GetStr(STATUSMSGINFO *n, const TCHAR *tmplt) { switch (tmplt[i]) { case 'n': - if (n->compare == 2 || _tcscmp(n->newstatusmsg, TranslateT("")) == 0) + if (n->compare == 2 || _tcscmp(n->newstatusmsg, TranslateT("")) == 0) lstrcpyn(tmp, TranslateT(""), SIZEOF(tmp)); else { TCHAR *_tmp = AddCR(n->newstatusmsg); @@ -491,7 +487,7 @@ TCHAR* GetStr(STATUSMSGINFO *n, const TCHAR *tmplt) { } break; case 'o': - if (n->oldstatusmsg == NULL || n->oldstatusmsg[0] == _T('\0') || _tcscmp(n->oldstatusmsg, TranslateT("")) == 0) + if (n->oldstatusmsg == NULL || n->oldstatusmsg[0] == _T('\0') || _tcscmp(n->oldstatusmsg, TranslateT("")) == 0) lstrcpyn(tmp, TranslateT(""), SIZEOF(tmp)); else { TCHAR *_tmp = AddCR(n->oldstatusmsg); @@ -548,16 +544,16 @@ TCHAR* GetStr(STATUSMSGINFO *n, const TCHAR *tmplt) { } } } - + return str; } int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) { - if (strcmp(cws->szSetting, "Status") == 0) + if (strcmp(cws->szSetting, "Status") == 0) { WORD newStatus = cws->value.wVal; - if (newStatus < ID_STATUS_MIN || newStatus > ID_STATUS_MAX) + if (newStatus < ID_STATUS_MIN || newStatus > ID_STATUS_MAX) return 0; DBVARIANT dbv; @@ -569,14 +565,14 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) } WORD oldStatus = DBGetContactSettingRangedWord(hContact, "UserOnline", "OldStatus", ID_STATUS_OFFLINE, ID_STATUS_MIN, ID_STATUS_MAX); - if (oldStatus == newStatus) + if (oldStatus == newStatus) return 0; //If we get here, the two stauses differ, so we can proceed. DBWriteContactSettingWord(hContact, "UserOnline", "OldStatus", newStatus); //If *Miranda* ignores the UserOnline event, exit! - if (CallService(MS_IGNORE_ISIGNORED, (WPARAM)hContact, IGNOREEVENT_USERONLINE)) + if (CallService(MS_IGNORE_ISIGNORED, (WPARAM)hContact, IGNOREEVENT_USERONLINE)) return 0; //If we get here, we have to notify the Hooks. @@ -673,7 +669,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) str = GetStr(&smi, dbVar.ptszVal); } mir_free(protoname); - + ppd.lchContact = smi.hContact; ppd.lchIcon = LoadSkinnedProtoIcon(smi.proto, DBGetContactSettingWord(smi.hContact, smi.proto, "Status", ID_STATUS_ONLINE)); lstrcpyn(ppd.lptzContactName, smi.cust, MAX_CONTACTNAME); @@ -694,7 +690,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) } ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; ppd.PluginData = NULL; - ppd.iSeconds = opt.PopupTimeout; + ppd.iSeconds = opt.PopupTimeout; PUAddPopUpT(&ppd); mir_free(str); } @@ -711,11 +707,11 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; HANDLE hContact = (HANDLE)wParam; - if (hContact == NULL) + if (hContact == NULL) return 0; char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto == NULL) + if (szProto == NULL) return 0; if (DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) @@ -731,9 +727,9 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) int StatusModeChanged(WPARAM wParam, LPARAM lParam) { char *szProto = (char *)lParam; - if (opt.AutoDisable && (!opt.OnlyGlobalChanges || szProto == NULL)) + if (opt.AutoDisable && (!opt.OnlyGlobalChanges || szProto == NULL)) { - if (opt.DisablePopupGlobally && ServiceExists(MS_POPUP_QUERY)) + if (opt.DisablePopupGlobally && ServiceExists(MS_POPUP_QUERY)) { char szSetting[12]; wsprintfA(szSetting, "p%d", wParam); @@ -744,25 +740,25 @@ int StatusModeChanged(WPARAM wParam, LPARAM lParam) BYTE hlpPopupStatus = (BYTE)CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0); opt.PopupAutoDisabled = hlpDisablePopup; - if (hlpDisablePopup) - { + if (hlpDisablePopup) + { DBWriteContactSettingByte(0, MODULE, "OldPopupStatus", hlpPopupStatus); CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0); - } + } else { - if (hlpPopupStatus == FALSE) + if (hlpPopupStatus == FALSE) { if (DBGetContactSettingByte(0, MODULE, "OldPopupStatus", TRUE) == TRUE) CallService(MS_POPUP_QUERY, PUQS_ENABLEPOPUPS, 0); else CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0); } - } + } } } - if (opt.DisableSoundGlobally) + if (opt.DisableSoundGlobally) { char szSetting[12]; wsprintfA(szSetting, "s%d", wParam); @@ -773,16 +769,16 @@ int StatusModeChanged(WPARAM wParam, LPARAM lParam) BYTE hlpUseSound = DBGetContactSettingByte(NULL, "Skin", "UseSound", 1); opt.SoundAutoDisabled = hlpDisableSound; - if (hlpDisableSound) - { + if (hlpDisableSound) + { DBWriteContactSettingByte(0, MODULE, "OldUseSound", hlpUseSound); - DBWriteContactSettingByte(0, "Skin", "UseSound", FALSE); - } + DBWriteContactSettingByte(0, "Skin", "UseSound", FALSE); + } else { if (hlpUseSound == FALSE) DBWriteContactSettingByte(0, "Skin", "UseSound", DBGetContactSettingByte(0, MODULE, "OldUseSound", 1)); - } + } } } } @@ -793,7 +789,7 @@ int StatusModeChanged(WPARAM wParam, LPARAM lParam) void ShowStatusChangePopup(HANDLE hContact, char *szProto, WORD oldStatus, WORD newStatus) { TCHAR stzStatusText[MAX_SECONDLINE] = {0}; - WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, (WPARAM)0, (LPARAM)0); + WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, (WPARAM)0, (LPARAM)0); POPUPDATAT ppd = {0}; ppd.lchContact = hContact; @@ -816,16 +812,16 @@ void ShowStatusChangePopup(HANDLE hContact, char *szProto, WORD oldStatus, WORD { if (opt.UseAlternativeText) { - switch (GetGender(hContact)) + switch (GetGender(hContact)) { case GENDER_MALE: - _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzMStatusText, MAX_STATUSTEXT); + _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzMStatusText, MAX_STATUSTEXT); break; case GENDER_FEMALE: - _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzFStatusText, MAX_STATUSTEXT); + _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzFStatusText, MAX_STATUSTEXT); break; case GENDER_UNSPECIFIED: - _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzUStatusText, MAX_STATUSTEXT); + _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzUStatusText, MAX_STATUSTEXT); break; } } @@ -834,7 +830,7 @@ void ShowStatusChangePopup(HANDLE hContact, char *szProto, WORD oldStatus, WORD _tcsncpy(stzStatusText, StatusList[Index(newStatus)].lpzStandardText, MAX_STATUSTEXT); } - if (opt.ShowPreviousStatus) + if (opt.ShowPreviousStatus) { TCHAR buff[MAX_STATUSTEXT]; wsprintf(buff, TranslateTS(STRING_SHOWPREVIOUSSTATUS), StatusList[Index(oldStatus)].lpzStandardText); @@ -842,8 +838,8 @@ void ShowStatusChangePopup(HANDLE hContact, char *szProto, WORD oldStatus, WORD } } - if (opt.ReadAwayMsg && - myStatus != ID_STATUS_INVISIBLE && + if (opt.ReadAwayMsg && + myStatus != ID_STATUS_INVISIBLE && StatusHasAwayMessage(szProto, newStatus)) { DBWriteContactSettingTString(hContact, MODULE, "LastPopupText", stzStatusText); @@ -874,7 +870,7 @@ void ShowStatusChangePopup(HANDLE hContact, char *szProto, WORD oldStatus, WORD pdp->hAwayMsgHook = NULL; pdp->hAwayMsgProcess = NULL; ppd.PluginData = pdp; - ppd.iSeconds = opt.PopupTimeout; + ppd.iSeconds = opt.PopupTimeout; PUAddPopUpT(&ppd); } @@ -906,8 +902,8 @@ void PlayChangeSound(HANDLE hContact, WORD oldStatus, WORD newStatus) { TCHAR stzSoundFile[MAX_PATH] = {0}; if (!DBGetContactSettingTString(hContact, MODULE, "UserFromOffline", &dbv) && - oldStatus == ID_STATUS_OFFLINE) - { + oldStatus == ID_STATUS_OFFLINE) + { _tcscpy(stzSoundFile, dbv.ptszVal); DBFreeVariant(&dbv); } @@ -924,19 +920,19 @@ void PlayChangeSound(HANDLE hContact, WORD oldStatus, WORD newStatus) CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)stzSoundFile, (LPARAM)stzSoundPath); PlaySound(stzSoundPath, NULL, SND_ASYNC | SND_FILENAME | SND_NOSTOP); return; - } + } } char szSoundFile[MAX_PATH] = {0}; - - if (!DBGetContactSettingByte(0, "SkinSoundsOff", "UserFromOffline", 0) && + + if (!DBGetContactSettingByte(0, "SkinSoundsOff", "UserFromOffline", 0) && !DBGetContactSettingString(0,"SkinSounds", "UserFromOffline", &dbv) && oldStatus == ID_STATUS_OFFLINE) - { + { strcpy(szSoundFile, "UserFromOffline"); DBFreeVariant(&dbv); } - else if (!DBGetContactSettingByte(0, "SkinSoundsOff", StatusList[Index(newStatus)].lpzSkinSoundName, 0) && + else if (!DBGetContactSettingByte(0, "SkinSoundsOff", StatusList[Index(newStatus)].lpzSkinSoundName, 0) && !DBGetContactSetting(0, "SkinSounds", StatusList[Index(newStatus)].lpzSkinSoundName, &dbv)) { strcpy(szSoundFile, StatusList[Index(newStatus)].lpzSkinSoundName); @@ -952,54 +948,54 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) WORD oldStatus = LOWORD(lParam); WORD newStatus = HIWORD(lParam); HANDLE hContact = (HANDLE)wParam; - char buff[8], szProto[64], szSubProto[64]; + char buff[8], szProto[64], szSubProto[64]; bool bEnablePopup = true, bEnableSound = true; char *hlpProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); - if (hlpProto == NULL || opt.TempDisabled) + if (hlpProto == NULL || opt.TempDisabled) return 0; strcpy(szProto, hlpProto); - WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, (WPARAM)0, (LPARAM)0); + WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, (WPARAM)0, (LPARAM)0); if (strcmp(szProto, szMetaModuleName) == 0) //this contact is Meta { - HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); + HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); strcpy(szSubProto, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSubContact,0)); - - if (newStatus == ID_STATUS_OFFLINE) + + if (newStatus == ID_STATUS_OFFLINE) { - // read last online proto for metaconatct if exists, + // read last online proto for metaconatct if exists, // to avoid notifying when meta went offline but default contact's proto still online - DBVARIANT dbv; + DBVARIANT dbv; if (!DBGetContactSettingString(hContact, szProto, "LastOnline", &dbv)) { strcpy(szSubProto, dbv.pszVal); DBFreeVariant(&dbv); - } + } } else DBWriteContactSettingString(hContact, szProto, "LastOnline", szSubProto); - if (!DBGetContactSettingByte(0, MODULE, szSubProto, 1)) - return 0; + if (!DBGetContactSettingByte(0, MODULE, szSubProto, 1)) + return 0; strcpy(szProto, szSubProto); } else { - if (myStatus == ID_STATUS_OFFLINE) + if (myStatus == ID_STATUS_OFFLINE) return 0; } - + if (!opt.FromOffline || oldStatus != ID_STATUS_OFFLINE) // Either it wasn't a change from Offline or we didn't enable that. - { - wsprintfA(buff, "%d", newStatus); - if (DBGetContactSettingByte(0, MODULE, buff, 1) == 0) + { + wsprintfA(buff, "%d", newStatus); + if (DBGetContactSettingByte(0, MODULE, buff, 1) == 0) return 0; // "Notify when a contact changes to one of..." is unchecked } - - if (!opt.HiddenContactsToo && (DBGetContactSettingByte(hContact, "CList", "Hidden", 0) == 1)) + + if (!opt.HiddenContactsToo && (DBGetContactSettingByte(hContact, "CList", "Hidden", 0) == 1)) return 0; // we don't want to be notified if new chatroom comes online @@ -1016,9 +1012,9 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) bEnablePopup = DBGetContactSettingByte(0, MODULE, statusIDp, 1) ? FALSE : TRUE; } - if (bEnablePopup && DBGetContactSettingByte(hContact, MODULE, "EnablePopups", 1) && TimeoutCheck()) + if (bEnablePopup && DBGetContactSettingByte(hContact, MODULE, "EnablePopups", 1) && TimeoutCheck()) ShowStatusChangePopup(hContact, szProto, oldStatus, newStatus); - + if (opt.BlinkIcon) BlinkIcon(hContact, szProto, newStatus); @@ -1029,7 +1025,7 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) PlayChangeSound(hContact, oldStatus, newStatus); } - if (opt.Log) + if (opt.Log) { TCHAR stzName[64], stzStatus[MAX_STATUSTEXT], stzOldStatus[MAX_STATUSTEXT]; TCHAR stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT]; @@ -1043,11 +1039,11 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) wsprintf(stzText, TranslateT("%s, %s. %s changed to: %s (was: %s).\r\n"), stzDate, stzTime, stzName, stzStatus, stzOldStatus); LogToFile(stzText); } - + return 0; -} +} -void InitStatusList() +void InitStatusList() { int index = 0; //Online @@ -1200,7 +1196,7 @@ void InitStatusList() void InitUpdaterSupport() { #ifndef _WIN64 - if (ServiceExists(MS_UPDATE_REGISTER)) + if (ServiceExists(MS_UPDATE_REGISTER)) { Update update = {0}; char szVersion[16]; @@ -1229,15 +1225,15 @@ int ProtoAck(WPARAM wParam,LPARAM lParam) WORD oldStatus = (WORD)ack->hProcess; char *szProto = (char *)ack->szModule; - if (oldStatus == newStatus) + if (oldStatus == newStatus) return 0; - if (newStatus == ID_STATUS_OFFLINE) + if (newStatus == ID_STATUS_OFFLINE) { //The protocol switched to offline. Disable the popups for this protocol DBWriteContactSettingByte(NULL, MODULE, szProto, 0); } - else if (oldStatus < ID_STATUS_ONLINE && newStatus >= ID_STATUS_ONLINE) + else if (oldStatus < ID_STATUS_ONLINE && newStatus >= ID_STATUS_ONLINE) { //The protocol changed from a disconnected status to a connected status. //Enable the popups for this protocol. @@ -1248,7 +1244,7 @@ int ProtoAck(WPARAM wParam,LPARAM lParam) return 0; } -INT_PTR EnableDisableMenuCommand(WPARAM wParam, LPARAM lParam) +INT_PTR EnableDisableMenuCommand(WPARAM wParam, LPARAM lParam) { opt.TempDisabled = !opt.TempDisabled; DBWriteContactSettingByte(0, MODULE, "TempDisable", opt.TempDisabled); @@ -1261,18 +1257,18 @@ INT_PTR EnableDisableMenuCommand(WPARAM wParam, LPARAM lParam) mi.ptszName = _T("Enable status notification"); mi.icolibItem = GetIconHandle(ICO_NOTIFICATION_OFF); } - else + else { mi.ptszName = _T("Disable status notification"); mi.icolibItem = GetIconHandle(ICO_NOTIFICATION_ON); } - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEnableDisableMenu, (LPARAM)&mi); + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEnableDisableMenu, (LPARAM)&mi); CallService(MS_TB_SETBUTTONSTATEBYID, (WPARAM)"StatusNotificationToggle", opt.TempDisabled ? TBST_PUSHED : TBST_RELEASED); return 0; } -void InitMainMenuItem() +void InitMainMenuItem() { CLISTMENUITEM mi = { 0 }; mi.cbSize = sizeof(mi); @@ -1284,7 +1280,7 @@ void InitMainMenuItem() opt.TempDisabled = !opt.TempDisabled; EnableDisableMenuCommand(0, 0); - hServiceMenu = (HANDLE)CreateServiceFunction(MS_STATUSCHANGE_MENUCOMMAND, EnableDisableMenuCommand); + hServiceMenu = (HANDLE)CreateServiceFunction(MS_STATUSCHANGE_MENUCOMMAND, EnableDisableMenuCommand); } struct _tag_iconList @@ -1313,7 +1309,7 @@ void InitIcolib() GetModuleFileNameA(hInst, szFile, MAX_PATH); - for (int i = 0; i < SIZEOF(iconList); i++) + for (int i = 0; i < SIZEOF(iconList); i++) { mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", MODULE, iconList[i].szName); sid.pszDescription = Translate(iconList[i].szDescr); @@ -1324,7 +1320,7 @@ void InitIcolib() void InitSound() { - for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) + for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) SkinAddNewSoundEx(StatusList[Index(i)].lpzSkinSoundName, LPGEN("Status Notify"), StatusList[Index(i)].lpzSkinSoundDesc); SkinAddNewSoundEx("UserFromOffline", LPGEN("Status Notify"), LPGEN("User: from offline (has priority!)")); @@ -1351,7 +1347,7 @@ void InitTopToolbar() } } -int ModulesLoaded(WPARAM wParam, LPARAM lParam) +int ModulesLoaded(WPARAM wParam, LPARAM lParam) { InitUpdaterSupport(); InitMainMenuItem(); @@ -1364,9 +1360,9 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) int count = 0; PROTOACCOUNT **accounts = NULL; CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&accounts); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { - if (IsAccountEnabled(accounts[i])) + if (IsAccountEnabled(accounts[i])) DBWriteContactSettingByte(NULL, MODULE, accounts[i]->szModuleName, 0); } @@ -1379,12 +1375,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) { pluginLink = link; - - if (mir_getMMI(&mmi) || mir_getLI(&li) || mir_getUTFI(&utfi)) - { - MessageBox(NULL, TranslateT("Cannot obtain required interfaces!\nPlugin will not be loaded until you upgrade Miranda IM to the newest version."), TranslateT("NewXstatusNotify"), MB_OK | MB_ICONSTOP); - return 1; - } mir_getLP(&pluginInfoEx); //"Service" Hook, used when the DB settings change: we'll monitor the "status" setting. diff --git a/plugins/NewXstatusNotify/options.cpp b/plugins/NewXstatusNotify/options.cpp index 5fc13a53ad..808092d498 100644 --- a/plugins/NewXstatusNotify/options.cpp +++ b/plugins/NewXstatusNotify/options.cpp @@ -29,7 +29,7 @@ OPTIONS opt = {0}; TEMPLATES templates = {0}; BOOL UpdateListFlag = FALSE; -SortedList *ProtoTemplates; +LIST ProtoTemplates(10); int LastItem = 0; extern HINSTANCE hInst; @@ -114,16 +114,13 @@ void SaveTemplates() DBWriteContactSettingTString(0, MODULE, "TLogOpening", templates.LogOpening); DBWriteContactSettingByte(0, MODULE, "TPopupFlags", templates.PopupFlags); DBWriteContactSettingByte(0, MODULE, "TLogFlags", templates.LogFlags); - if(ProtoTemplates!=NULL) - { - for (int i = 0; i < ProtoTemplates->realCount; i++) - { - PROTOTEMPLATE *prototemplate = (PROTOTEMPLATE *)ProtoTemplates->items[i]; - TCHAR str[MAX_PATH]; - mir_sntprintf(str, SIZEOF(str), _T("%s_TSMChange"), prototemplate->ProtoName); - char *szstr = mir_t2a(str); - DBWriteContactSettingTString(0, MODULE, szstr, prototemplate->ProtoTemplate); - } + + for (int i = 0; i < ProtoTemplates.getCount(); i++) { + PROTOTEMPLATE *prototemplate = ProtoTemplates[i]; + TCHAR str[MAX_PATH]; + mir_sntprintf(str, SIZEOF(str), _T("%s_TSMChange"), prototemplate->ProtoName); + char *szstr = mir_t2a(str); + DBWriteContactSettingTString(0, MODULE, szstr, prototemplate->ProtoTemplate); } } @@ -712,11 +709,10 @@ bool IsSuitableProto( PROTOACCOUNT* pa ) INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { - case WM_INITDIALOG: + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); { - TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg, IDC_ONCONNECT, opt.PopupOnConnect); CheckDlgButton(hwndDlg, IDC_PUIGNOREREMOVE, opt.IgnoreEmpty); @@ -748,9 +744,8 @@ INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA int count; PROTOACCOUNT** protos; ProtoEnumAccounts( &count, &protos ); - ProtoTemplates = li.List_Create(0, 10); - for(int i=0;iProtoTemplate, TranslateT(DEFAULT_POPUP_STATUSMESSAGE), SIZEOF(prototemplate->ProtoTemplate)); } - else - { - _tcsncpy(prototemplate->ProtoTemplate, dbVar.ptszVal, SIZEOF(prototemplate->ProtoTemplate)); - } + else _tcsncpy(prototemplate->ProtoTemplate, dbVar.ptszVal, SIZEOF(prototemplate->ProtoTemplate)); + mir_free(szprotoname); ListView_InsertItem(hList,&lvItem); - li.List_Insert(ProtoTemplates, prototemplate, ProtoTemplates->realCount); + ProtoTemplates.insert(prototemplate, ProtoTemplates.getCount()); char dbSetting[128]; mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_enabled", protos[i]->szModuleName); @@ -783,106 +775,94 @@ INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA lvItem.iItem++; } UpdateListFlag = FALSE; - return TRUE; } - case WM_COMMAND: - { - switch (HIWORD(wParam)) - { - case BN_CLICKED: - { - switch (LOWORD(wParam)) - { - case IDC_BT_VARIABLES: - MessageBox(0, VARIABLES_SM_HELP_TEXT, TranslateT("Variables"), MB_OK | MB_ICONINFORMATION); - break; - - case IDC_BT_RESET: - if (ResetTemplatesToDefault(hwndDlg) == IDYES) break; - else return FALSE; - } + return TRUE; + + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDC_BT_VARIABLES: + MessageBox(0, VARIABLES_SM_HELP_TEXT, TranslateT("Variables"), MB_OK | MB_ICONINFORMATION); + break; + + case IDC_BT_RESET: + if (ResetTemplatesToDefault(hwndDlg) == IDYES) break; + else return FALSE; + } - if (LOWORD(wParam) != IDC_BT_VARIABLES) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + if (LOWORD(wParam) != IDC_BT_VARIABLES) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - case EN_CHANGE: - { - if ((HWND)lParam == GetFocus()) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } + break; - } - return TRUE; + case EN_CHANGE: + if ((HWND)lParam == GetFocus()) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; } - case WM_NOTIFY: - { - if (((NMHDR*)lParam)->idFrom == IDC_PROTOCOLLIST) { - switch(((NMHDR*)lParam)->code) { - case LVN_ITEMCHANGED: + return TRUE; + + case WM_NOTIFY: + if (((NMHDR*)lParam)->idFrom == IDC_PROTOCOLLIST) { + switch(((NMHDR*)lParam)->code) { + case LVN_ITEMCHANGED: + { + NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; + if (nmlv->uNewState == 3 && !UpdateListFlag) { - NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; - if (nmlv->uNewState == 3 && !UpdateListFlag) - { - HWND hList = GetDlgItem(hwndDlg,IDC_PROTOCOLLIST); - PROTOTEMPLATE *prototemplate; - if (ListView_GetHotItem(hList) != ListView_GetSelectionMark(hList)) - { - prototemplate = (PROTOTEMPLATE *)ProtoTemplates->items[ListView_GetSelectionMark(hList)]; - GetDlgItemText(hwndDlg, IDC_POPUPTEXT, prototemplate->ProtoTemplate, MAX_PATH); - li.List_Remove(ProtoTemplates, ListView_GetSelectionMark(hList)); - li.List_Insert(ProtoTemplates, prototemplate, ListView_GetSelectionMark(hList)); + HWND hList = GetDlgItem(hwndDlg,IDC_PROTOCOLLIST); + PROTOTEMPLATE *prototemplate; + if (ListView_GetHotItem(hList) != ListView_GetSelectionMark(hList)) { + prototemplate = ProtoTemplates[ListView_GetSelectionMark(hList)]; + GetDlgItemText(hwndDlg, IDC_POPUPTEXT, prototemplate->ProtoTemplate, MAX_PATH); + ProtoTemplates.remove( ListView_GetSelectionMark(hList)); + ProtoTemplates.insert(prototemplate, ListView_GetSelectionMark(hList)); - } - LastItem = ListView_GetHotItem(hList); - prototemplate = (PROTOTEMPLATE *)ProtoTemplates->items[LastItem]; - SetDlgItemText(hwndDlg, IDC_POPUPTEXT, prototemplate->ProtoTemplate); } - if ((nmlv->uNewState^nmlv->uOldState)&LVIS_STATEIMAGEMASK && !UpdateListFlag) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + LastItem = ListView_GetHotItem(hList); + prototemplate = ProtoTemplates[LastItem]; + SetDlgItemText(hwndDlg, IDC_POPUPTEXT, prototemplate->ProtoTemplate); } - break; - } } - if (((LPNMHDR)lParam)->code == PSN_APPLY ) - { + if ((nmlv->uNewState^nmlv->uOldState)&LVIS_STATEIMAGEMASK && !UpdateListFlag) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + } + } - opt.IgnoreEmpty = IsDlgButtonChecked(hwndDlg, IDC_PUIGNOREREMOVE); - opt.PopupOnConnect = IsDlgButtonChecked(hwndDlg, IDC_ONCONNECT); + if (((LPNMHDR)lParam)->code == PSN_APPLY ) { + opt.IgnoreEmpty = IsDlgButtonChecked(hwndDlg, IDC_PUIGNOREREMOVE); + opt.PopupOnConnect = IsDlgButtonChecked(hwndDlg, IDC_ONCONNECT); - // Templates - PROTOTEMPLATE *prototemplate = (PROTOTEMPLATE *)ProtoTemplates->items[LastItem]; - GetDlgItemText(hwndDlg, IDC_POPUPTEXT, prototemplate->ProtoTemplate, MAX_PATH); - li.List_Remove(ProtoTemplates, LastItem); - li.List_Insert(ProtoTemplates, prototemplate, LastItem); + // Templates + PROTOTEMPLATE *prototemplate = ProtoTemplates[LastItem]; + GetDlgItemText(hwndDlg, IDC_POPUPTEXT, prototemplate->ProtoTemplate, MAX_PATH); + ProtoTemplates.remove(LastItem); + ProtoTemplates.insert(prototemplate, LastItem); + + // Save options to db + SaveOptions(); + SaveTemplates(); + HWND hList = GetDlgItem(hwndDlg,IDC_PROTOCOLLIST); + LVITEM lvItem = {0}; + lvItem.mask=LVIF_PARAM; + for (int i=0;i