From e82e5f12414a1045f2914f5c03cf5ae831e1a9fb Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sat, 23 Jun 2012 15:47:55 +0000 Subject: SeenPlugin: plusified git-svn-id: http://svn.miranda-ng.org/main/trunk@564 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SeenPlugin/main.cpp | 51 +++------------- plugins/SeenPlugin/seen.h | 13 ++++- plugins/SeenPlugin/seenplugin_10.vcxproj | 16 ++--- plugins/SeenPlugin/seenplugin_10.vcxproj.filters | 16 ++--- plugins/SeenPlugin/utils.cpp | 74 ++++++++++++------------ 5 files changed, 72 insertions(+), 98 deletions(-) (limited to 'plugins/SeenPlugin') diff --git a/plugins/SeenPlugin/main.cpp b/plugins/SeenPlugin/main.cpp index dd9a91b840..949a898cd6 100644 --- a/plugins/SeenPlugin/main.cpp +++ b/plugins/SeenPlugin/main.cpp @@ -24,23 +24,22 @@ Last change by : $Author: y_b $ */ #include "seen.h" - HINSTANCE hInstance; HANDLE ehdb = NULL, ehproto = NULL, ehmissed = NULL, ehuserinfo = NULL, ehmissed_proto = NULL, hOptInit = NULL, hMainInit = NULL; PLUGINLINK *pluginLink; struct MM_INTERFACE mmi; int hLangpack; -char authemail[] = "fscking@spammer.oip.info";//the correct e-mail shall be constructed in DllMain + PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), "Last seen", PLUGIN_MAKE_VERSION(5,0,4,7), "Log when a user was last seen online and which users were online while you were away.", "Heiko Schillinger, YB", - authemail, + "y_b@saaplugin.no-ip.info", "© 2001-2002 Heiko Schillinger, 2003 modified by Bruno Rino, 2005-7 Modified by YB", "http://forums.miranda-im.org/showthread.php?t=2822", - 0, + UNICODE_AWARE, 0, { 0x2d506d46,0xc94e,0x4ef8,{0x85, 0x37, 0xf1, 0x12, 0x33, 0xa8, 0x03, 0x81}}/* 2d506d46-c94e-4ef8-8537-f11233a80381 */ }; @@ -51,24 +50,10 @@ DBVTranslation idleTr[TRANSNUMBER]={ {(TranslateFunc*)any_to_Idle, _T("Any to /Idle or empty"),0} }; - - -int OptionsInit(WPARAM,LPARAM); -int UserinfoInit(WPARAM,LPARAM); -int InitFileOutput(void); -void InitMenuitem(void); -int UpdateValues(WPARAM,LPARAM); -int ModeChange(WPARAM,LPARAM); -//int GetInfoAck(WPARAM,LPARAM); -void SetOffline(void); -int ModeChange_mo(WPARAM,LPARAM); -int CheckIfOnline(void); - BOOL includeIdle; logthread_info **contactQueue = NULL; int contactQueueSize = 0; - int MainInit(WPARAM wparam,LPARAM lparam) { contactQueueSize = 16*sizeof(logthread_info *); @@ -91,7 +76,7 @@ int MainInit(WPARAM wparam,LPARAM lparam) if(DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)) ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); - ehdb = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,UpdateValues); + ehdb = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UpdateValues); ehproto = HookEvent(ME_PROTO_ACK,ModeChange); SkinAddNewSoundEx("LastSeenTrackedStatusChange", LPGEN("LastSeen"), LPGEN("User status change")); @@ -114,20 +99,12 @@ int MainInit(WPARAM wparam,LPARAM lparam) return 0; } -__declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion) +extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion) { - pluginInfo.cbSize = sizeof( PLUGININFOEX ); return &pluginInfo; } -#define MIID_LASTSEEN {0x0df23e71, 0x7950, 0x43d5, {0xb9, 0x86, 0x7a, 0xbf, 0xf5, 0xa5, 0x40, 0x18}} -static const MUUID interfaces[] = {MIID_LASTSEEN, MIID_LAST}; -__declspec(dllexport) const MUUID * MirandaPluginInterfaces(void) -{ - return interfaces; -} - -__declspec(dllexport)int Unload(void) +extern "C" __declspec(dllexport) int Unload(void) { UnhookEvent(ehdb); if(ehmissed) UnhookEvent(ehmissed); @@ -141,18 +118,13 @@ __declspec(dllexport)int Unload(void) return 0; } - - -BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved) +BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved) { - memcpy(pluginInfo.authorEmail,"y_b@saaplugin.no-",17); hInstance=hinst; return 1; } - - -int __declspec(dllexport)Load(PLUGINLINK *link) +extern "C" __declspec(dllexport) int Load(PLUGINLINK *link) { pluginLink=link; mir_getMMI(&mmi); @@ -164,9 +136,4 @@ int __declspec(dllexport)Load(PLUGINLINK *link) // to be safer in my opinion hMainInit = HookEvent(ME_SYSTEM_MODULESLOADED,MainInit); return 0; -} - - - - - +} \ No newline at end of file diff --git a/plugins/SeenPlugin/seen.h b/plugins/SeenPlugin/seen.h index 745788d3c1..ba2b13a6c2 100644 --- a/plugins/SeenPlugin/seen.h +++ b/plugins/SeenPlugin/seen.h @@ -105,16 +105,23 @@ typedef struct{ BYTE times[1024]; } MISSEDCONTACTS; -/* utils.c */ int IsWatchedProtocol(const char* szProto); char *ParseString(char *,HANDLE,BYTE); extern DWORD StatusColors15bits[]; void GetColorsFromDWord(LPCOLORREF First, LPCOLORREF Second, DWORD colDword); DWORD GetDWordFromColors(COLORREF First, COLORREF Second); - +int OptionsInit(WPARAM,LPARAM); +int UserinfoInit(WPARAM,LPARAM); +int InitFileOutput(void); +void InitMenuitem(void); +int UpdateValues(WPARAM, LPARAM); +int ModeChange(WPARAM,LPARAM); +void SetOffline(void); +int ModeChange_mo(WPARAM,LPARAM); +int CheckIfOnline(void); void UninitMenuitem(); -BOOL includeIdle; +extern BOOL includeIdle; typedef struct logthread_info { char sProtoName[MAXMODULELABELLENGTH]; HANDLE hContact; diff --git a/plugins/SeenPlugin/seenplugin_10.vcxproj b/plugins/SeenPlugin/seenplugin_10.vcxproj index ee9fb530c6..95609282a4 100644 --- a/plugins/SeenPlugin/seenplugin_10.vcxproj +++ b/plugins/SeenPlugin/seenplugin_10.vcxproj @@ -172,14 +172,14 @@ - - - - - - - - + + + + + + + + diff --git a/plugins/SeenPlugin/seenplugin_10.vcxproj.filters b/plugins/SeenPlugin/seenplugin_10.vcxproj.filters index 99de7b53e9..01ad56020d 100644 --- a/plugins/SeenPlugin/seenplugin_10.vcxproj.filters +++ b/plugins/SeenPlugin/seenplugin_10.vcxproj.filters @@ -15,28 +15,28 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/plugins/SeenPlugin/utils.cpp b/plugins/SeenPlugin/utils.cpp index 4d0e64d00c..1cfc5a2a82 100644 --- a/plugins/SeenPlugin/utils.cpp +++ b/plugins/SeenPlugin/utils.cpp @@ -576,7 +576,7 @@ int addContactToQueue(HANDLE hContact){ } for (i=1;iqueueIndex = i; contactQueue[i]->hContact = hContact; return i; @@ -587,7 +587,7 @@ int addContactToQueue(HANDLE hContact){ contactQueue = (logthread_info **)realloc(contactQueue,(contactQueueSize+16)*sizeof(logthread_info *)); memset(&contactQueue[contactQueueSize],0, 16*sizeof(logthread_info *)); i = contactQueueSize; - contactQueue[i] = malloc(sizeof(logthread_info)); + contactQueue[i] = (logthread_info *)malloc(sizeof(logthread_info)); contactQueue[i]->queueIndex = i; contactQueue[i]->hContact = hContact; contactQueueSize += 16; @@ -631,23 +631,23 @@ static DWORD __stdcall waitThread(logthread_info* infoParam) -int UpdateValues(HANDLE hContact,LPARAM lparam) +int UpdateValues(WPARAM wparam,LPARAM lparam) { FORK_THREADEX_PARAMS params; DWORD dwThreadId; DBCONTACTWRITESETTING *cws; BOOL isIdleEvent; // to make this code faster - if (!hContact) return 0; + if (!wparam) return 0; cws=(DBCONTACTWRITESETTING *)lparam; //if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hContact,IGNOREEVENT_USERONLINE)) return 0; isIdleEvent = includeIdle?(strcmp(cws->szSetting,"IdleTS")==0):0; if (strcmp(cws->szSetting,"Status") && strcmp(cws->szSetting,"StatusTriger") && (isIdleEvent==0)) return 0; if (!strcmp(cws->szModule,S_MOD)) { //here we will come when Settings/SeenModule/StatusTriger is changed - WORD prevStatus=DBGetContactSettingWord(hContact,S_MOD,"OldStatus",ID_STATUS_OFFLINE); + WORD prevStatus=DBGetContactSettingWord((HANDLE)wparam, S_MOD, "OldStatus", ID_STATUS_OFFLINE); if (includeIdle){ - if (DBGetContactSettingByte(hContact,S_MOD,"OldIdle",0)) prevStatus &= 0x7FFF; + if (DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OldIdle", 0)) prevStatus &= 0x7FFF; else prevStatus |= 0x8000; } if ((cws->value.wVal|0x8000)<=ID_STATUS_OFFLINE) @@ -656,77 +656,77 @@ int UpdateValues(HANDLE hContact,LPARAM lparam) // avoid repeating the offline status if ((prevStatus|0x8000)<=ID_STATUS_OFFLINE) return 0; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); - DBWriteContactSettingByte(hContact,S_MOD,"Offline",1); + proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0); + DBWriteContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 1); { DWORD t; - char *str = malloc(MAXMODULELABELLENGTH+9); + char *str = (char *)malloc(MAXMODULELABELLENGTH+9); mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",proto); t = DBGetContactSettingDword(NULL,S_MOD,str,0); if (!t) t = time(NULL); free(str); - DBWriteTimeTS(t,hContact); + DBWriteTimeTS(t, (HANDLE)wparam); } if (!DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)) { char * sProto; if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) - FileWrite(hContact); + FileWrite((HANDLE)wparam); if (CallProtoService(sProto = - (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0), + (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), PS_GETSTATUS,0,0 )>ID_STATUS_OFFLINE) { - myPlaySound(hContact,ID_STATUS_OFFLINE,prevStatus); - if(DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)) { - ShowPopup(hContact,sProto,ID_STATUS_OFFLINE); + myPlaySound((HANDLE)wparam, ID_STATUS_OFFLINE, prevStatus); + if(DBGetContactSettingByte(NULL, S_MOD, "UsePopups", 0)) { + ShowPopup((HANDLE)wparam, sProto, ID_STATUS_OFFLINE); } } - if(DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0)) - HistoryWrite(hContact); + if(DBGetContactSettingByte(NULL, S_MOD, "KeepHistory", 0)) + HistoryWrite((HANDLE)wparam); - if(DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) - ShowHistory(hContact, 1); + if(DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) + ShowHistory((HANDLE)wparam, 1); } } else { - if(cws->value.wVal==prevStatus && !DBGetContactSettingByte(hContact,S_MOD,"Offline",0)) + if(cws->value.wVal==prevStatus && !DBGetContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 0)) return 0; - DBWriteTimeTS(time(NULL),hContact); + DBWriteTimeTS(time(NULL), (HANDLE)wparam); //DBWriteContactSettingWord(hContact,S_MOD,"StatusTriger",(WORD)cws->value.wVal); - if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) FileWrite(hContact); - if (prevStatus != cws->value.wVal) myPlaySound(hContact,cws->value.wVal,prevStatus); - if(DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)) - if (prevStatus != cws->value.wVal) ShowPopup(hContact,(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0),cws->value.wVal|0x8000); + if(DBGetContactSettingByte(NULL, S_MOD, "FileOutput", 0)) FileWrite((HANDLE)wparam); + if (prevStatus != cws->value.wVal) myPlaySound((HANDLE)wparam, cws->value.wVal, prevStatus); + if(DBGetContactSettingByte(NULL, S_MOD, "UsePopups", 0)) + if (prevStatus != cws->value.wVal) ShowPopup((HANDLE)wparam, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), cws->value.wVal|0x8000); - if(DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0)) HistoryWrite(hContact); - if(DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) ShowHistory(hContact, 1); - DBWriteContactSettingByte(hContact,S_MOD,"Offline",0); + if(DBGetContactSettingByte(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite((HANDLE)wparam); + if(DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) ShowHistory((HANDLE)wparam, 1); + DBWriteContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 0); } } else if (IsWatchedProtocol(cws->szModule)) { //here we will come when //Status is changed or it is idle event and if is watched if (CallProtoService(cws->szModule,PS_GETSTATUS,0,0)>ID_STATUS_OFFLINE){ int index; - if (!(index = isContactQueueActive(hContact))) { - index = addContactToQueue(hContact); + if (!(index = isContactQueueActive((HANDLE)wparam))) { + index = addContactToQueue((HANDLE)wparam); strncpy(contactQueue[index]->sProtoName,cws->szModule,MAXMODULELABELLENGTH); //forkthreadex(NULL, 0, waitThread, contactQueue[index], 0, 0); - params.pFunc = waitThread; + params.pFunc = (pThreadFuncEx)waitThread; params.arg = contactQueue[index]; params.iStackSize = 0; - params.threadID = &dwThreadId; + params.threadID = (unsigned int *)&dwThreadId; CallService(MS_SYSTEM_FORK_THREAD_EX, 0, (LPARAM)¶ms); // } else { // MessageBox(0,"Already in contact queue",cws->szModule,0); } - contactQueue[index]->courStatus = isIdleEvent?DBGetContactSettingWord(hContact,cws->szModule,"Status",ID_STATUS_OFFLINE):cws->value.wVal; + contactQueue[index]->courStatus = isIdleEvent ? DBGetContactSettingWord((HANDLE)wparam, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal; } } return 0; @@ -770,7 +770,7 @@ static DWORD __stdcall cleanThread(logthread_info* infoParam) // (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) // ); { - char *str = malloc(MAXMODULELABELLENGTH+9); + char *str = (char *)malloc(MAXMODULELABELLENGTH+9); mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",infoParam->sProtoName); DBDeleteContactSetting(NULL,S_MOD,str); free(str); @@ -813,17 +813,17 @@ int ModeChange(WPARAM wparam,LPARAM lparam) info->hContact = 0; info->courStatus = 0; //forkthreadex(NULL, 0, cleanThread, info, 0, 0); - params.pFunc = cleanThread; + params.pFunc = (pThreadFuncEx)cleanThread; params.arg = info; params.iStackSize = 0; - params.threadID = &dwThreadId; + params.threadID = (unsigned int *)&dwThreadId; CallService(MS_SYSTEM_FORK_THREAD_EX, 0, (LPARAM)¶ms); } } else if ((isetting==ID_STATUS_OFFLINE)&&((WORD)ack->hProcess>ID_STATUS_OFFLINE)) { //we have just loged-off if (IsWatchedProtocol(ack->szModule)) { - char *str = malloc(MAXMODULELABELLENGTH+9); + char *str = (char *)malloc(MAXMODULELABELLENGTH+9); time_t t; time(&t); mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",ack->szModule); -- cgit v1.2.3