From 49f674c71a033583c59aac67d6720fcb72cc28a4 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sat, 23 Jun 2012 15:47:13 +0000 Subject: SeenPlugin: renamed to .cpp git-svn-id: http://svn.miranda-ng.org/main/trunk@563 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SeenPlugin/file.c | 119 ------ plugins/SeenPlugin/file.cpp | 119 ++++++ plugins/SeenPlugin/history.c | 347 --------------- plugins/SeenPlugin/history.cpp | 347 +++++++++++++++ plugins/SeenPlugin/main.c | 172 -------- plugins/SeenPlugin/main.cpp | 172 ++++++++ plugins/SeenPlugin/menu.c | 113 ----- plugins/SeenPlugin/menu.cpp | 113 +++++ plugins/SeenPlugin/missed.c | 301 ------------- plugins/SeenPlugin/missed.cpp | 301 +++++++++++++ plugins/SeenPlugin/options.c | 494 --------------------- plugins/SeenPlugin/options.cpp | 494 +++++++++++++++++++++ plugins/SeenPlugin/userinfo.c | 95 ----- plugins/SeenPlugin/userinfo.cpp | 95 +++++ plugins/SeenPlugin/utils.c | 924 ---------------------------------------- plugins/SeenPlugin/utils.cpp | 924 ++++++++++++++++++++++++++++++++++++++++ 16 files changed, 2565 insertions(+), 2565 deletions(-) delete mode 100644 plugins/SeenPlugin/file.c create mode 100644 plugins/SeenPlugin/file.cpp delete mode 100644 plugins/SeenPlugin/history.c create mode 100644 plugins/SeenPlugin/history.cpp delete mode 100644 plugins/SeenPlugin/main.c create mode 100644 plugins/SeenPlugin/main.cpp delete mode 100644 plugins/SeenPlugin/menu.c create mode 100644 plugins/SeenPlugin/menu.cpp delete mode 100644 plugins/SeenPlugin/missed.c create mode 100644 plugins/SeenPlugin/missed.cpp delete mode 100644 plugins/SeenPlugin/options.c create mode 100644 plugins/SeenPlugin/options.cpp delete mode 100644 plugins/SeenPlugin/userinfo.c create mode 100644 plugins/SeenPlugin/userinfo.cpp delete mode 100644 plugins/SeenPlugin/utils.c create mode 100644 plugins/SeenPlugin/utils.cpp (limited to 'plugins/SeenPlugin') diff --git a/plugins/SeenPlugin/file.c b/plugins/SeenPlugin/file.c deleted file mode 100644 index cac37f8c30..0000000000 --- a/plugins/SeenPlugin/file.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/file.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ - -#include "seen.h" -/* -Prepares the log file: -- calculates the absolute path (and store it in the db) -- creates the directory - -*/ -int InitFileOutput(void) -{ - char szfpath[256]="",szmpath[256]="",*str; - DBVARIANT dbv; - - GetModuleFileName(NULL,szmpath,MAX_PATH); - strcpy(szfpath,!DBGetContactSetting(NULL,S_MOD,"FileName",&dbv)?dbv.pszVal:DEFAULT_FILENAME); - - DBFreeVariant(&dbv); - - if(szfpath[0]=='\\') - strcpy(szfpath,szfpath+1); - - str=strrchr(szmpath,'\\'); - if(str!=NULL) - *++str=0; - - strcat(szmpath,szfpath); - - strcpy(szfpath,szmpath); - - str=strrchr(szmpath,'\\'); - if(str!=NULL) - *++str=0; -/* -//we dont need this anylonger. the directory is created in filewrite - if (!CreateDirectory(szmpath,NULL)) - { - if (!(GetFileAttributes(szmpath) & FILE_ATTRIBUTE_DIRECTORY)) - { - MessageBox(NULL,"Directory could not be created\nPlease choose another!","Last seen plugin",MB_OK|MB_ICONERROR); - DBWriteContactSettingByte(NULL,S_MOD,"FileOutput",0); - return 0; - } - } -*/ - DBWriteContactSettingString(NULL,S_MOD,"PathToFile",szfpath); - - return 0; -} - -//borrowed from netliblog.c -static void CreateDirectoryTree(char *szDir) -{ - DWORD dwAttributes; - char *pszLastBackslash,szTestDir[MAX_PATH]; - - lstrcpynA(szTestDir,szDir,sizeof(szTestDir)); - if ((dwAttributes=GetFileAttributesA(szTestDir))!=0xffffffff && dwAttributes&FILE_ATTRIBUTE_DIRECTORY) return; - pszLastBackslash=strrchr(szTestDir,'\\'); - if(pszLastBackslash==NULL) return; - *pszLastBackslash='\0'; - CreateDirectoryTree(szTestDir); - CreateDirectoryA(szTestDir,NULL); -} - -/* -Writes a line into the log. -*/ -void FileWrite(HANDLE hcontact) -{ - HANDLE fhout; - DWORD byteswritten; - char szout[1024],sznl[3]="\r\n"; - DBVARIANT dbv; - - DBGetContactSetting(NULL,S_MOD,"PathToFile",&dbv); - strcpy(szout,ParseString(dbv.pszVal,hcontact,1)); - fhout=CreateFile(szout,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); - if (fhout==INVALID_HANDLE_VALUE){ - CreateDirectoryTree(szout); - fhout=CreateFile(szout,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); - if (fhout==INVALID_HANDLE_VALUE) return; - } - DBFreeVariant(&dbv); - SetFilePointer(fhout,0,0,FILE_END); - - strcpy(szout,ParseString(!DBGetContactSetting(NULL,S_MOD,"FileStamp",&dbv)?dbv.pszVal:DEFAULT_FILESTAMP,hcontact,1)); - DBFreeVariant(&dbv); - - WriteFile(fhout,szout, (DWORD)_tcslen(szout),&byteswritten,NULL); - WriteFile(fhout,sznl, (DWORD)_tcslen(sznl),&byteswritten,NULL); - - CloseHandle(fhout); - - -} diff --git a/plugins/SeenPlugin/file.cpp b/plugins/SeenPlugin/file.cpp new file mode 100644 index 0000000000..cac37f8c30 --- /dev/null +++ b/plugins/SeenPlugin/file.cpp @@ -0,0 +1,119 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/file.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ + +#include "seen.h" +/* +Prepares the log file: +- calculates the absolute path (and store it in the db) +- creates the directory + +*/ +int InitFileOutput(void) +{ + char szfpath[256]="",szmpath[256]="",*str; + DBVARIANT dbv; + + GetModuleFileName(NULL,szmpath,MAX_PATH); + strcpy(szfpath,!DBGetContactSetting(NULL,S_MOD,"FileName",&dbv)?dbv.pszVal:DEFAULT_FILENAME); + + DBFreeVariant(&dbv); + + if(szfpath[0]=='\\') + strcpy(szfpath,szfpath+1); + + str=strrchr(szmpath,'\\'); + if(str!=NULL) + *++str=0; + + strcat(szmpath,szfpath); + + strcpy(szfpath,szmpath); + + str=strrchr(szmpath,'\\'); + if(str!=NULL) + *++str=0; +/* +//we dont need this anylonger. the directory is created in filewrite + if (!CreateDirectory(szmpath,NULL)) + { + if (!(GetFileAttributes(szmpath) & FILE_ATTRIBUTE_DIRECTORY)) + { + MessageBox(NULL,"Directory could not be created\nPlease choose another!","Last seen plugin",MB_OK|MB_ICONERROR); + DBWriteContactSettingByte(NULL,S_MOD,"FileOutput",0); + return 0; + } + } +*/ + DBWriteContactSettingString(NULL,S_MOD,"PathToFile",szfpath); + + return 0; +} + +//borrowed from netliblog.c +static void CreateDirectoryTree(char *szDir) +{ + DWORD dwAttributes; + char *pszLastBackslash,szTestDir[MAX_PATH]; + + lstrcpynA(szTestDir,szDir,sizeof(szTestDir)); + if ((dwAttributes=GetFileAttributesA(szTestDir))!=0xffffffff && dwAttributes&FILE_ATTRIBUTE_DIRECTORY) return; + pszLastBackslash=strrchr(szTestDir,'\\'); + if(pszLastBackslash==NULL) return; + *pszLastBackslash='\0'; + CreateDirectoryTree(szTestDir); + CreateDirectoryA(szTestDir,NULL); +} + +/* +Writes a line into the log. +*/ +void FileWrite(HANDLE hcontact) +{ + HANDLE fhout; + DWORD byteswritten; + char szout[1024],sznl[3]="\r\n"; + DBVARIANT dbv; + + DBGetContactSetting(NULL,S_MOD,"PathToFile",&dbv); + strcpy(szout,ParseString(dbv.pszVal,hcontact,1)); + fhout=CreateFile(szout,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); + if (fhout==INVALID_HANDLE_VALUE){ + CreateDirectoryTree(szout); + fhout=CreateFile(szout,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); + if (fhout==INVALID_HANDLE_VALUE) return; + } + DBFreeVariant(&dbv); + SetFilePointer(fhout,0,0,FILE_END); + + strcpy(szout,ParseString(!DBGetContactSetting(NULL,S_MOD,"FileStamp",&dbv)?dbv.pszVal:DEFAULT_FILESTAMP,hcontact,1)); + DBFreeVariant(&dbv); + + WriteFile(fhout,szout, (DWORD)_tcslen(szout),&byteswritten,NULL); + WriteFile(fhout,sznl, (DWORD)_tcslen(sznl),&byteswritten,NULL); + + CloseHandle(fhout); + + +} diff --git a/plugins/SeenPlugin/history.c b/plugins/SeenPlugin/history.c deleted file mode 100644 index 724cfd5612..0000000000 --- a/plugins/SeenPlugin/history.c +++ /dev/null @@ -1,347 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-06 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/history.c $ -Revision : $Rev: 1056 $ -Last change on : $Date: 2006-10-30 06:22:07 +0300 (Пн, 30 окт 2006) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - - -extern HINSTANCE hInstance; - -static HANDLE hWindowList; - -char* BuildSetting(int historyLast) { - static char setting[15]; - static char sztemp[15]; - *setting = '\0'; - strcat(setting, "History_"); - strcat(setting, itoa(historyLast, sztemp, 10)); - return setting; -} - -void HistoryWrite(HANDLE hContact) -{ - short historyFirst, historyLast, historyMax; - DBVARIANT dbv; - - historyMax = DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10); - if (historyMax < 0) historyMax=0; else if (historyMax > 99) historyMax = 99; - if (historyMax == 0) return; - historyFirst = DBGetContactSettingWord(hContact,S_MOD,"HistoryFirst",0); - if (historyFirst >= historyMax) historyFirst = 0; - historyLast = DBGetContactSettingWord(hContact,S_MOD,"HistoryLast",0); - if (historyLast >= historyMax) historyLast = historyMax-1; - - DBWriteContactSettingString(hContact,S_MOD,BuildSetting(historyLast), - ParseString(!DBGetContactSetting(NULL,S_MOD,"HistoryStamp",&dbv)?dbv.pszVal:DEFAULT_HISTORYSTAMP,hContact,0)); - DBFreeVariant(&dbv); - - historyLast = (historyLast+1) % historyMax; - DBWriteContactSettingWord(hContact,S_MOD,"HistoryLast",historyLast); - if (historyLast == historyFirst) { - DBWriteContactSettingWord(hContact,S_MOD,"HistoryFirst",(short) ((historyFirst+1) % historyMax)); - } - -} - -void LoadHistoryList(HANDLE hContact, HWND hwnd, int nList) { - short historyFirst, historyLast, historyMax; - short i; - DBVARIANT dbv; - - - SendDlgItemMessage(hwnd, nList, LB_RESETCONTENT, 0, 0); - historyMax = DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10); - if (historyMax < 0) historyMax = 0; else if (historyMax > 99) historyMax = 99; - if (historyMax == 0) return; - historyFirst = DBGetContactSettingWord(hContact,S_MOD,"HistoryFirst",0); - if (historyFirst >= historyMax) historyFirst = 0; - historyLast = DBGetContactSettingWord(hContact,S_MOD,"HistoryLast",0); - if (historyLast >= historyMax) historyLast = historyMax-1; - - i = historyLast; - while (i != historyFirst) { - i = (i-1+historyMax) % historyMax; - SendDlgItemMessage(hwnd, nList, LB_ADDSTRING, 0, - (LPARAM)(!DBGetContactSetting(hContact,S_MOD,BuildSetting(i),&dbv)?dbv.pszVal:"")); - DBFreeVariant(&dbv); - } - -} - - -HDWP MyResizeWindow (HDWP hDwp, HWND hwndDlg, HWND hwndControl, - int nHorizontalOffset, int nVerticalOffset, - int nWidthOffset, int nHeightOffset) -{ - POINT pt; - RECT rcinit; - - // get current bounding rectangle - GetWindowRect(hwndControl, &rcinit); - - // get current top left point - pt.x = rcinit.left; - pt.y = rcinit.top; - ScreenToClient(hwndDlg, &pt); - - // resize control -/* MoveWindow(hwndControl, - pt.x + nHorizontalOffset, - pt.y + nVerticalOffset, - rcinit.right - rcinit.left + nWidthOffset, - rcinit.bottom - rcinit.top + nHeightOffset, - FALSE); -*/ - return DeferWindowPos(hDwp, hwndControl, NULL, - pt.x + nHorizontalOffset, - pt.y + nVerticalOffset, - rcinit.right - rcinit.left + nWidthOffset, - rcinit.bottom - rcinit.top + nHeightOffset, - SWP_NOZORDER); - - -} - -HDWP MyHorizCenterWindow (HDWP hDwp, HWND hwndDlg, HWND hwndControl, - int nClientWidth, int nVerticalOffset, - int nHeightOffset) -{ - POINT pt; - RECT rcinit; - - // get current bounding rectangle - GetWindowRect(hwndControl, &rcinit); - - // get current top left point - pt.x = rcinit.left; - pt.y = rcinit.top; - ScreenToClient(hwndDlg, &pt); - - // resize control -/* MoveWindow(hwndControl, - (int) ((nClientWidth - (rcinit.right - rcinit.left))/2), - pt.y + nVerticalOffset, - rcinit.right - rcinit.left, - rcinit.bottom - rcinit.top + nHeightOffset, - TRUE); -*/ - return DeferWindowPos(hDwp, hwndControl, NULL, - (int) ((nClientWidth - (rcinit.right - rcinit.left))/2), - pt.y + nVerticalOffset, - rcinit.right - rcinit.left, - rcinit.bottom - rcinit.top + nHeightOffset, - SWP_NOZORDER); - -} -void MyResizeGetOffset (HWND hwndDlg, HWND hwndControl, - int nWidth, int nHeight, - int* nDx, int* nDy) -{ - RECT rcinit; - - // get current bounding rectangle - GetWindowRect(hwndControl, &rcinit); - - // calculate offsets - *nDx = nWidth - (rcinit.right - rcinit.left); - *nDy = nHeight - (rcinit.bottom - rcinit.top); -} - -INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARAM lparam) -{ - HANDLE hContact; - char sztemp[1024]=""; - static HIMAGELIST hIml=NULL; - - switch(Message) - { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - hContact = (HANDLE)lparam; - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lparam); - strcpy(sztemp,(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0)); - strcat(sztemp, ": "); - strcat(sztemp, Translate("last seen history")); - SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)sztemp); - SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); - SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_SMALL, (LPARAM) LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); - -// LoadHistoryList(hContact, hwndDlg, IDC_HISTORYLIST); - - if (DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) - SendDlgItemMessage(hwndDlg, IDC_STATUSCHANGE, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); - { - hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,3,3); - ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_USERDETAILS))); - ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DOWNARROW))); - ImageList_AddIcon(hIml,LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); - SendDlgItemMessage(hwndDlg,IDC_DETAILS,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,0,ILD_NORMAL)); - SendDlgItemMessage(hwndDlg,IDC_USERMENU,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,1,ILD_NORMAL)); - SendDlgItemMessage(hwndDlg,IDC_SENDMSG,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,2,ILD_NORMAL)); - } - - //set-up tooltips - { - HWND hwndDlgToolTips; - TOOLINFO ti; - - hwndDlgToolTips = CreateWindowEx(WS_EX_TOPMOST,TOOLTIPS_CLASS,"",WS_POPUP,0,0,0,0,NULL,NULL,GetModuleHandle(NULL),NULL); - ZeroMemory(&ti,sizeof(ti)); - ti.cbSize=sizeof(ti); - ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS; - ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_USERMENU); - ti.lpszText=Translate("User Menu"); - SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); - ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_DETAILS); - ti.lpszText=Translate("View User's Details"); - SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); - ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_SENDMSG); - ti.lpszText=Translate("Send Instant Message"); - SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); - } - - - Utils_RestoreWindowPositionNoMove(hwndDlg,NULL,S_MOD,"History_"); - ShowWindow(hwndDlg, SW_SHOW); - break; - - case WM_MEASUREITEM: - return CallService(MS_CLIST_MENUMEASUREITEM,wparam,lparam); - case WM_DRAWITEM: - return CallService(MS_CLIST_MENUDRAWITEM,wparam,lparam); - case WM_COMMAND: - hContact=(HANDLE)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); - if(CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wparam),MPCF_CONTACTMENU),(LPARAM)hContact)) - break; - switch(LOWORD(wparam)) - { - case IDCANCEL: - SendMessage(hwndDlg, WM_CLOSE, 0, 0); - break; - case IDOK: - if (SendDlgItemMessage(hwndDlg, IDC_STATUSCHANGE, BM_GETCHECK, 0, 0) == BST_CHECKED) - DBWriteContactSettingByte(hContact,S_MOD,"OnlineAlert",1); - else - DBWriteContactSettingByte(hContact,S_MOD,"OnlineAlert",0); - SendMessage(hwndDlg, WM_CLOSE, 0, 0); - break; - case IDC_USERMENU: - { - RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,(WPARAM)hContact,0); - GetWindowRect(GetDlgItem(hwndDlg,IDC_USERMENU),&rc); - TrackPopupMenu(hMenu,0,rc.left,rc.bottom,0,hwndDlg,NULL); - DestroyMenu(hMenu); - } - break; - case IDC_DETAILS: - CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)hContact,0); - break; - case IDC_SENDMSG: - CallService(MS_MSG_SENDMESSAGE,(WPARAM)hContact,0); - break; - case IDC_TEST: - debug(ParseString("Date: %d.%m.%y(%Y) \n Date desc: %W - %w - %E - %e \n Time: %H:%M:%S (%h-%p) \n user: %n - %u \n Status: %s \n IP: %i - %r",hContact,0)); - break; - } - break; - case WM_SIZE: - { - int dx, dy; - HDWP hDwp; - - hDwp = BeginDeferWindowPos(6); - MyResizeGetOffset(hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), - LOWORD(lparam)-15, HIWORD(lparam)-99, &dx, &dy); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_USERMENU), - dx, 0, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_DETAILS), - dx, 0, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_SENDMSG), - dx, 0, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), - 0, 0, dx, dy); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_STATUSCHANGE), - 0, dy, dx, 0); - hDwp = MyHorizCenterWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDOK), - LOWORD(lparam), dy, 0); - EndDeferWindowPos(hDwp); - } - break; - case WM_GETMINMAXINFO: - { - MINMAXINFO mmi; - CopyMemory (&mmi, (LPMINMAXINFO) lparam, sizeof (MINMAXINFO)); - - /* The minimum width in points*/ - mmi.ptMinTrackSize.x = 200; - /* The minimum height in points*/ - mmi.ptMinTrackSize.y = 190; - - CopyMemory ((LPMINMAXINFO) lparam, &mmi, sizeof (MINMAXINFO)); - } - break; - - case WM_CLOSE: - DestroyWindow(hwndDlg); - WindowList_Remove(hWindowList,hwndDlg); - break; - case WM_DESTROY: - Utils_SaveWindowPosition(hwndDlg,NULL,S_MOD,"History_"); - ImageList_Destroy(hIml); - break; - default: - return FALSE; - } - return TRUE; -} - -void ShowHistory(HANDLE hContact, BYTE isAlert) -{ - HWND hHistoryDlg; - - hHistoryDlg = WindowList_Find(hWindowList,hContact); - if (hHistoryDlg == NULL) - { - hHistoryDlg = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_HISTORY),NULL,HistoryDlgProc,(LPARAM)hContact); - LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); - WindowList_Add(hWindowList,hHistoryDlg,hContact); - } - else - { - SetForegroundWindow(hHistoryDlg); - LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); - SetFocus(hHistoryDlg); - } - - if (isAlert) - { - SkinPlaySound("LastSeenTrackedStatusChange"); - } -} - - -void InitHistoryDialog(void) -{ - hWindowList=(HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0); -} diff --git a/plugins/SeenPlugin/history.cpp b/plugins/SeenPlugin/history.cpp new file mode 100644 index 0000000000..724cfd5612 --- /dev/null +++ b/plugins/SeenPlugin/history.cpp @@ -0,0 +1,347 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-06 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/history.c $ +Revision : $Rev: 1056 $ +Last change on : $Date: 2006-10-30 06:22:07 +0300 (Пн, 30 окт 2006) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + + +extern HINSTANCE hInstance; + +static HANDLE hWindowList; + +char* BuildSetting(int historyLast) { + static char setting[15]; + static char sztemp[15]; + *setting = '\0'; + strcat(setting, "History_"); + strcat(setting, itoa(historyLast, sztemp, 10)); + return setting; +} + +void HistoryWrite(HANDLE hContact) +{ + short historyFirst, historyLast, historyMax; + DBVARIANT dbv; + + historyMax = DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10); + if (historyMax < 0) historyMax=0; else if (historyMax > 99) historyMax = 99; + if (historyMax == 0) return; + historyFirst = DBGetContactSettingWord(hContact,S_MOD,"HistoryFirst",0); + if (historyFirst >= historyMax) historyFirst = 0; + historyLast = DBGetContactSettingWord(hContact,S_MOD,"HistoryLast",0); + if (historyLast >= historyMax) historyLast = historyMax-1; + + DBWriteContactSettingString(hContact,S_MOD,BuildSetting(historyLast), + ParseString(!DBGetContactSetting(NULL,S_MOD,"HistoryStamp",&dbv)?dbv.pszVal:DEFAULT_HISTORYSTAMP,hContact,0)); + DBFreeVariant(&dbv); + + historyLast = (historyLast+1) % historyMax; + DBWriteContactSettingWord(hContact,S_MOD,"HistoryLast",historyLast); + if (historyLast == historyFirst) { + DBWriteContactSettingWord(hContact,S_MOD,"HistoryFirst",(short) ((historyFirst+1) % historyMax)); + } + +} + +void LoadHistoryList(HANDLE hContact, HWND hwnd, int nList) { + short historyFirst, historyLast, historyMax; + short i; + DBVARIANT dbv; + + + SendDlgItemMessage(hwnd, nList, LB_RESETCONTENT, 0, 0); + historyMax = DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10); + if (historyMax < 0) historyMax = 0; else if (historyMax > 99) historyMax = 99; + if (historyMax == 0) return; + historyFirst = DBGetContactSettingWord(hContact,S_MOD,"HistoryFirst",0); + if (historyFirst >= historyMax) historyFirst = 0; + historyLast = DBGetContactSettingWord(hContact,S_MOD,"HistoryLast",0); + if (historyLast >= historyMax) historyLast = historyMax-1; + + i = historyLast; + while (i != historyFirst) { + i = (i-1+historyMax) % historyMax; + SendDlgItemMessage(hwnd, nList, LB_ADDSTRING, 0, + (LPARAM)(!DBGetContactSetting(hContact,S_MOD,BuildSetting(i),&dbv)?dbv.pszVal:"")); + DBFreeVariant(&dbv); + } + +} + + +HDWP MyResizeWindow (HDWP hDwp, HWND hwndDlg, HWND hwndControl, + int nHorizontalOffset, int nVerticalOffset, + int nWidthOffset, int nHeightOffset) +{ + POINT pt; + RECT rcinit; + + // get current bounding rectangle + GetWindowRect(hwndControl, &rcinit); + + // get current top left point + pt.x = rcinit.left; + pt.y = rcinit.top; + ScreenToClient(hwndDlg, &pt); + + // resize control +/* MoveWindow(hwndControl, + pt.x + nHorizontalOffset, + pt.y + nVerticalOffset, + rcinit.right - rcinit.left + nWidthOffset, + rcinit.bottom - rcinit.top + nHeightOffset, + FALSE); +*/ + return DeferWindowPos(hDwp, hwndControl, NULL, + pt.x + nHorizontalOffset, + pt.y + nVerticalOffset, + rcinit.right - rcinit.left + nWidthOffset, + rcinit.bottom - rcinit.top + nHeightOffset, + SWP_NOZORDER); + + +} + +HDWP MyHorizCenterWindow (HDWP hDwp, HWND hwndDlg, HWND hwndControl, + int nClientWidth, int nVerticalOffset, + int nHeightOffset) +{ + POINT pt; + RECT rcinit; + + // get current bounding rectangle + GetWindowRect(hwndControl, &rcinit); + + // get current top left point + pt.x = rcinit.left; + pt.y = rcinit.top; + ScreenToClient(hwndDlg, &pt); + + // resize control +/* MoveWindow(hwndControl, + (int) ((nClientWidth - (rcinit.right - rcinit.left))/2), + pt.y + nVerticalOffset, + rcinit.right - rcinit.left, + rcinit.bottom - rcinit.top + nHeightOffset, + TRUE); +*/ + return DeferWindowPos(hDwp, hwndControl, NULL, + (int) ((nClientWidth - (rcinit.right - rcinit.left))/2), + pt.y + nVerticalOffset, + rcinit.right - rcinit.left, + rcinit.bottom - rcinit.top + nHeightOffset, + SWP_NOZORDER); + +} +void MyResizeGetOffset (HWND hwndDlg, HWND hwndControl, + int nWidth, int nHeight, + int* nDx, int* nDy) +{ + RECT rcinit; + + // get current bounding rectangle + GetWindowRect(hwndControl, &rcinit); + + // calculate offsets + *nDx = nWidth - (rcinit.right - rcinit.left); + *nDy = nHeight - (rcinit.bottom - rcinit.top); +} + +INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARAM lparam) +{ + HANDLE hContact; + char sztemp[1024]=""; + static HIMAGELIST hIml=NULL; + + switch(Message) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + hContact = (HANDLE)lparam; + SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lparam); + strcpy(sztemp,(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0)); + strcat(sztemp, ": "); + strcat(sztemp, Translate("last seen history")); + SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)sztemp); + SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); + SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_SMALL, (LPARAM) LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); + +// LoadHistoryList(hContact, hwndDlg, IDC_HISTORYLIST); + + if (DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) + SendDlgItemMessage(hwndDlg, IDC_STATUSCHANGE, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); + { + hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,3,3); + ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_USERDETAILS))); + ImageList_AddIcon(hIml,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DOWNARROW))); + ImageList_AddIcon(hIml,LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); + SendDlgItemMessage(hwndDlg,IDC_DETAILS,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,0,ILD_NORMAL)); + SendDlgItemMessage(hwndDlg,IDC_USERMENU,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,1,ILD_NORMAL)); + SendDlgItemMessage(hwndDlg,IDC_SENDMSG,BM_SETIMAGE,IMAGE_ICON,(WPARAM)ImageList_GetIcon(hIml,2,ILD_NORMAL)); + } + + //set-up tooltips + { + HWND hwndDlgToolTips; + TOOLINFO ti; + + hwndDlgToolTips = CreateWindowEx(WS_EX_TOPMOST,TOOLTIPS_CLASS,"",WS_POPUP,0,0,0,0,NULL,NULL,GetModuleHandle(NULL),NULL); + ZeroMemory(&ti,sizeof(ti)); + ti.cbSize=sizeof(ti); + ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS; + ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_USERMENU); + ti.lpszText=Translate("User Menu"); + SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); + ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_DETAILS); + ti.lpszText=Translate("View User's Details"); + SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); + ti.uId=(UINT)GetDlgItem(hwndDlg,IDC_SENDMSG); + ti.lpszText=Translate("Send Instant Message"); + SendMessage(hwndDlgToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); + } + + + Utils_RestoreWindowPositionNoMove(hwndDlg,NULL,S_MOD,"History_"); + ShowWindow(hwndDlg, SW_SHOW); + break; + + case WM_MEASUREITEM: + return CallService(MS_CLIST_MENUMEASUREITEM,wparam,lparam); + case WM_DRAWITEM: + return CallService(MS_CLIST_MENUDRAWITEM,wparam,lparam); + case WM_COMMAND: + hContact=(HANDLE)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); + if(CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wparam),MPCF_CONTACTMENU),(LPARAM)hContact)) + break; + switch(LOWORD(wparam)) + { + case IDCANCEL: + SendMessage(hwndDlg, WM_CLOSE, 0, 0); + break; + case IDOK: + if (SendDlgItemMessage(hwndDlg, IDC_STATUSCHANGE, BM_GETCHECK, 0, 0) == BST_CHECKED) + DBWriteContactSettingByte(hContact,S_MOD,"OnlineAlert",1); + else + DBWriteContactSettingByte(hContact,S_MOD,"OnlineAlert",0); + SendMessage(hwndDlg, WM_CLOSE, 0, 0); + break; + case IDC_USERMENU: + { + RECT rc; + HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,(WPARAM)hContact,0); + GetWindowRect(GetDlgItem(hwndDlg,IDC_USERMENU),&rc); + TrackPopupMenu(hMenu,0,rc.left,rc.bottom,0,hwndDlg,NULL); + DestroyMenu(hMenu); + } + break; + case IDC_DETAILS: + CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)hContact,0); + break; + case IDC_SENDMSG: + CallService(MS_MSG_SENDMESSAGE,(WPARAM)hContact,0); + break; + case IDC_TEST: + debug(ParseString("Date: %d.%m.%y(%Y) \n Date desc: %W - %w - %E - %e \n Time: %H:%M:%S (%h-%p) \n user: %n - %u \n Status: %s \n IP: %i - %r",hContact,0)); + break; + } + break; + case WM_SIZE: + { + int dx, dy; + HDWP hDwp; + + hDwp = BeginDeferWindowPos(6); + MyResizeGetOffset(hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), + LOWORD(lparam)-15, HIWORD(lparam)-99, &dx, &dy); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_USERMENU), + dx, 0, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_DETAILS), + dx, 0, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_SENDMSG), + dx, 0, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), + 0, 0, dx, dy); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_STATUSCHANGE), + 0, dy, dx, 0); + hDwp = MyHorizCenterWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDOK), + LOWORD(lparam), dy, 0); + EndDeferWindowPos(hDwp); + } + break; + case WM_GETMINMAXINFO: + { + MINMAXINFO mmi; + CopyMemory (&mmi, (LPMINMAXINFO) lparam, sizeof (MINMAXINFO)); + + /* The minimum width in points*/ + mmi.ptMinTrackSize.x = 200; + /* The minimum height in points*/ + mmi.ptMinTrackSize.y = 190; + + CopyMemory ((LPMINMAXINFO) lparam, &mmi, sizeof (MINMAXINFO)); + } + break; + + case WM_CLOSE: + DestroyWindow(hwndDlg); + WindowList_Remove(hWindowList,hwndDlg); + break; + case WM_DESTROY: + Utils_SaveWindowPosition(hwndDlg,NULL,S_MOD,"History_"); + ImageList_Destroy(hIml); + break; + default: + return FALSE; + } + return TRUE; +} + +void ShowHistory(HANDLE hContact, BYTE isAlert) +{ + HWND hHistoryDlg; + + hHistoryDlg = WindowList_Find(hWindowList,hContact); + if (hHistoryDlg == NULL) + { + hHistoryDlg = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_HISTORY),NULL,HistoryDlgProc,(LPARAM)hContact); + LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); + WindowList_Add(hWindowList,hHistoryDlg,hContact); + } + else + { + SetForegroundWindow(hHistoryDlg); + LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); + SetFocus(hHistoryDlg); + } + + if (isAlert) + { + SkinPlaySound("LastSeenTrackedStatusChange"); + } +} + + +void InitHistoryDialog(void) +{ + hWindowList=(HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0); +} diff --git a/plugins/SeenPlugin/main.c b/plugins/SeenPlugin/main.c deleted file mode 100644 index dd9a91b840..0000000000 --- a/plugins/SeenPlugin/main.c +++ /dev/null @@ -1,172 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/main.c $ -Revision : $Rev: 1571 $ -Last change on : $Date: 2007-12-30 04:55:51 +0300 (Вс, 30 дек 2007) $ -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, - " 2001-2002 Heiko Schillinger, 2003 modified by Bruno Rino, 2005-7 Modified by YB", - "http://forums.miranda-im.org/showthread.php?t=2822", - 0, - 0, - { 0x2d506d46,0xc94e,0x4ef8,{0x85, 0x37, 0xf1, 0x12, 0x33, 0xa8, 0x03, 0x81}}/* 2d506d46-c94e-4ef8-8537-f11233a80381 */ -}; - -#define TRANSNUMBER 2 -DBVTranslation idleTr[TRANSNUMBER]={ - {(TranslateFunc*)any_to_IdleNotidleUnknown, _T("Any to Idle/Not Idle/Unknown"),0}, - {(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 *); - contactQueue = (logthread_info **)malloc(contactQueueSize); - memset(&contactQueue[0], 0, contactQueueSize); - contactQueueSize = 16; - includeIdle = (BOOL )DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1); - hOptInit = HookEvent(ME_OPT_INITIALISE, OptionsInit); - - if(DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) { - InitMenuitem(); - } - - if(DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1)) - ehuserinfo = HookEvent(ME_USERINFO_INITIALISE,UserinfoInit); - - if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) - InitFileOutput(); - - if(DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)) - ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); - - ehdb = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,UpdateValues); - ehproto = HookEvent(ME_PROTO_ACK,ModeChange); - - SkinAddNewSoundEx("LastSeenTrackedStatusChange", LPGEN("LastSeen"), LPGEN("User status change")); - SkinAddNewSoundEx("LastSeenTrackedStatusOnline", LPGEN("LastSeen"), LPGEN("Changed to Online")); - SkinAddNewSoundEx("LastSeenTrackedStatusOffline", LPGEN("LastSeen"), LPGEN("User Logged Off")); - SkinAddNewSoundEx("LastSeenTrackedStatusFromOffline", LPGEN("LastSeen"), LPGEN("User Logged In")); - - // known modules list - if (ServiceExists("DBEditorpp/RegisterSingleModule")) - CallService("DBEditorpp/RegisterSingleModule", (WPARAM)S_MOD, 0); - DBWriteContactSettingString(NULL,"Uninstall",Translate("Last seen"),S_MOD); - - - if ( ServiceExists(MS_TIPPER_ADDTRANSLATION)) { - int i; - for (i=0; i < TRANSNUMBER; i++) - CallService(MS_TIPPER_ADDTRANSLATION, 0, (LPARAM)&idleTr[i]); - } - - return 0; -} - -__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) -{ - UnhookEvent(ehdb); - if(ehmissed) UnhookEvent(ehmissed); - UnhookEvent(ehproto); - if(ehmissed_proto) UnhookEvent(ehmissed_proto); - UnhookEvent(hOptInit); - UnhookEvent(hMainInit); - if (ehuserinfo) UnhookEvent(ehuserinfo); - UninitMenuitem(); -// free(contactQueue); - return 0; -} - - - -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) -{ - pluginLink=link; - mir_getMMI(&mmi); - mir_getLP(&pluginInfo); - // this isn't required for most events - // but the ME_USERINFO_INITIALISE - // I decided to hook all events after - // everything is loaded because it seems - // to be safer in my opinion - hMainInit = HookEvent(ME_SYSTEM_MODULESLOADED,MainInit); - return 0; -} - - - - - diff --git a/plugins/SeenPlugin/main.cpp b/plugins/SeenPlugin/main.cpp new file mode 100644 index 0000000000..dd9a91b840 --- /dev/null +++ b/plugins/SeenPlugin/main.cpp @@ -0,0 +1,172 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/main.c $ +Revision : $Rev: 1571 $ +Last change on : $Date: 2007-12-30 04:55:51 +0300 (Вс, 30 дек 2007) $ +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, + " 2001-2002 Heiko Schillinger, 2003 modified by Bruno Rino, 2005-7 Modified by YB", + "http://forums.miranda-im.org/showthread.php?t=2822", + 0, + 0, + { 0x2d506d46,0xc94e,0x4ef8,{0x85, 0x37, 0xf1, 0x12, 0x33, 0xa8, 0x03, 0x81}}/* 2d506d46-c94e-4ef8-8537-f11233a80381 */ +}; + +#define TRANSNUMBER 2 +DBVTranslation idleTr[TRANSNUMBER]={ + {(TranslateFunc*)any_to_IdleNotidleUnknown, _T("Any to Idle/Not Idle/Unknown"),0}, + {(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 *); + contactQueue = (logthread_info **)malloc(contactQueueSize); + memset(&contactQueue[0], 0, contactQueueSize); + contactQueueSize = 16; + includeIdle = (BOOL )DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1); + hOptInit = HookEvent(ME_OPT_INITIALISE, OptionsInit); + + if(DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) { + InitMenuitem(); + } + + if(DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1)) + ehuserinfo = HookEvent(ME_USERINFO_INITIALISE,UserinfoInit); + + if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) + InitFileOutput(); + + if(DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)) + ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); + + ehdb = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,UpdateValues); + ehproto = HookEvent(ME_PROTO_ACK,ModeChange); + + SkinAddNewSoundEx("LastSeenTrackedStatusChange", LPGEN("LastSeen"), LPGEN("User status change")); + SkinAddNewSoundEx("LastSeenTrackedStatusOnline", LPGEN("LastSeen"), LPGEN("Changed to Online")); + SkinAddNewSoundEx("LastSeenTrackedStatusOffline", LPGEN("LastSeen"), LPGEN("User Logged Off")); + SkinAddNewSoundEx("LastSeenTrackedStatusFromOffline", LPGEN("LastSeen"), LPGEN("User Logged In")); + + // known modules list + if (ServiceExists("DBEditorpp/RegisterSingleModule")) + CallService("DBEditorpp/RegisterSingleModule", (WPARAM)S_MOD, 0); + DBWriteContactSettingString(NULL,"Uninstall",Translate("Last seen"),S_MOD); + + + if ( ServiceExists(MS_TIPPER_ADDTRANSLATION)) { + int i; + for (i=0; i < TRANSNUMBER; i++) + CallService(MS_TIPPER_ADDTRANSLATION, 0, (LPARAM)&idleTr[i]); + } + + return 0; +} + +__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) +{ + UnhookEvent(ehdb); + if(ehmissed) UnhookEvent(ehmissed); + UnhookEvent(ehproto); + if(ehmissed_proto) UnhookEvent(ehmissed_proto); + UnhookEvent(hOptInit); + UnhookEvent(hMainInit); + if (ehuserinfo) UnhookEvent(ehuserinfo); + UninitMenuitem(); +// free(contactQueue); + return 0; +} + + + +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) +{ + pluginLink=link; + mir_getMMI(&mmi); + mir_getLP(&pluginInfo); + // this isn't required for most events + // but the ME_USERINFO_INITIALISE + // I decided to hook all events after + // everything is loaded because it seems + // to be safer in my opinion + hMainInit = HookEvent(ME_SYSTEM_MODULESLOADED,MainInit); + return 0; +} + + + + + diff --git a/plugins/SeenPlugin/menu.c b/plugins/SeenPlugin/menu.c deleted file mode 100644 index 02f241b793..0000000000 --- a/plugins/SeenPlugin/menu.c +++ /dev/null @@ -1,113 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/menu.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - -HANDLE hmenuitem=NULL, hLSUserDet = NULL, hBuildMenu = NULL; - -void ShowHistory(HANDLE hContact, BYTE isAlert); -void InitHistoryDialog(void); - -/* -Handles the messages sent by clicking the contact's menu item -*/ -INT_PTR MenuitemClicked(WPARAM wparam,LPARAM lparam) -{ - ShowHistory((HANDLE)wparam, 0); - return 0; -} - -int BuildContactMenu(WPARAM wparam,LPARAM lparam) -{ - CLISTMENUITEM cmi; - DBVARIANT dbv; - int id=-1,isetting; - HANDLE hContact; - char *szProto; - - hContact = (HANDLE)wparam; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); - - ZeroMemory(&cmi,sizeof(cmi)); - cmi.cbSize=sizeof(cmi); - if (!IsWatchedProtocol(szProto) || !DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) - { - cmi.flags=CMIM_FLAGS|CMIF_HIDDEN; - } - else - { - cmi.flags=CMIM_NAME|CMIM_FLAGS|CMIM_ICON; - cmi.hIcon=NULL; - cmi.pszName=ParseString(!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP,(HANDLE)wparam,0); - - if (!strcmp(cmi.pszName,Translate(""))) - { - if (IsWatchedProtocol(szProto)) - cmi.flags|=CMIF_GRAYED; - else - cmi.flags|=CMIF_HIDDEN; - } - else if(DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)) - { - isetting=DBGetContactSettingWord((HANDLE)hContact,S_MOD,"StatusTriger",-1); - cmi.hIcon=LoadSkinnedProtoIcon(szProto,isetting|0x8000); - - } - } - - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hmenuitem,(LPARAM)&cmi); - DBFreeVariant(&dbv); - - return 0; -} - - - -void InitMenuitem() -{ - CLISTMENUITEM cmi; - - hLSUserDet = CreateServiceFunction("LastSeenUserDetails", MenuitemClicked); - - ZeroMemory(&cmi,sizeof(cmi)); - cmi.cbSize=sizeof(cmi); - cmi.flags=0; - cmi.hIcon=NULL; - cmi.hotKey=0; - cmi.position=-0x7FFFFFFF; - cmi.pszContactOwner=NULL; - cmi.pszName=""; - cmi.pszService="LastSeenUserDetails"; - hmenuitem = Menu_AddContactMenuItem(&cmi); - - hBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU,BuildContactMenu); - - InitHistoryDialog(); -} - -void UninitMenuitem() -{ - DestroyServiceFunction(hLSUserDet); - UnhookEvent(hBuildMenu); -} \ No newline at end of file diff --git a/plugins/SeenPlugin/menu.cpp b/plugins/SeenPlugin/menu.cpp new file mode 100644 index 0000000000..02f241b793 --- /dev/null +++ b/plugins/SeenPlugin/menu.cpp @@ -0,0 +1,113 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/menu.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + +HANDLE hmenuitem=NULL, hLSUserDet = NULL, hBuildMenu = NULL; + +void ShowHistory(HANDLE hContact, BYTE isAlert); +void InitHistoryDialog(void); + +/* +Handles the messages sent by clicking the contact's menu item +*/ +INT_PTR MenuitemClicked(WPARAM wparam,LPARAM lparam) +{ + ShowHistory((HANDLE)wparam, 0); + return 0; +} + +int BuildContactMenu(WPARAM wparam,LPARAM lparam) +{ + CLISTMENUITEM cmi; + DBVARIANT dbv; + int id=-1,isetting; + HANDLE hContact; + char *szProto; + + hContact = (HANDLE)wparam; + szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + + ZeroMemory(&cmi,sizeof(cmi)); + cmi.cbSize=sizeof(cmi); + if (!IsWatchedProtocol(szProto) || !DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) + { + cmi.flags=CMIM_FLAGS|CMIF_HIDDEN; + } + else + { + cmi.flags=CMIM_NAME|CMIM_FLAGS|CMIM_ICON; + cmi.hIcon=NULL; + cmi.pszName=ParseString(!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP,(HANDLE)wparam,0); + + if (!strcmp(cmi.pszName,Translate(""))) + { + if (IsWatchedProtocol(szProto)) + cmi.flags|=CMIF_GRAYED; + else + cmi.flags|=CMIF_HIDDEN; + } + else if(DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)) + { + isetting=DBGetContactSettingWord((HANDLE)hContact,S_MOD,"StatusTriger",-1); + cmi.hIcon=LoadSkinnedProtoIcon(szProto,isetting|0x8000); + + } + } + + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hmenuitem,(LPARAM)&cmi); + DBFreeVariant(&dbv); + + return 0; +} + + + +void InitMenuitem() +{ + CLISTMENUITEM cmi; + + hLSUserDet = CreateServiceFunction("LastSeenUserDetails", MenuitemClicked); + + ZeroMemory(&cmi,sizeof(cmi)); + cmi.cbSize=sizeof(cmi); + cmi.flags=0; + cmi.hIcon=NULL; + cmi.hotKey=0; + cmi.position=-0x7FFFFFFF; + cmi.pszContactOwner=NULL; + cmi.pszName=""; + cmi.pszService="LastSeenUserDetails"; + hmenuitem = Menu_AddContactMenuItem(&cmi); + + hBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU,BuildContactMenu); + + InitHistoryDialog(); +} + +void UninitMenuitem() +{ + DestroyServiceFunction(hLSUserDet); + UnhookEvent(hBuildMenu); +} \ No newline at end of file diff --git a/plugins/SeenPlugin/missed.c b/plugins/SeenPlugin/missed.c deleted file mode 100644 index 179dd8ee4d..0000000000 --- a/plugins/SeenPlugin/missed.c +++ /dev/null @@ -1,301 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/missed.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - -#include - - - -MISSEDCONTACTS mcs; -extern HANDLE ehmissed; -extern HINSTANCE hInstance; - - - -WPARAM IsUserMissed(WPARAM contact) -{ - int loop=0; - - for (;loopszSetting,"Status") || (strcmp(cws->szModule,"ICQ") && strcmp(cws->szModule,"MSN")) || (HANDLE)wparam==NULL) return 0; - - if(CallService(MS_IGNORE_ISIGNORED,wparam,IGNOREEVENT_USERONLINE)) - return 0; - - if(cws->value.wVal==ID_STATUS_OFFLINE) - { - if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==1) - { - mcs.times[mcs.count]++; - mcs.wpcontact[mcs.count++]=wparam; - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0); - } - - else if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==3) - mcs.times[HIWORD(IsUserMissed(wparam))]++; - - return 0; - } - - wpvar=IsUserMissed(wparam); - if(LOWORD(wpvar)) - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",3); - - else - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",1); - - return 0; -} - -*/ - -int Test(WPARAM wparam,LPARAM lparam) -{ - if(lparamICON_INVIS) - return 0; - - if(CallService(MS_IGNORE_ISIGNORED,wparam,IGNOREEVENT_USERONLINE)) - return 0; - - if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==2) - return 0; - - switch(lparam){ - - case ICON_OFFLINE: - if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==1) - { - WORD missed=IsUserMissed(wparam); - - if (!LOWORD(missed)) - { - mcs.times[mcs.count]=1; - mcs.wpcontact[mcs.count++]=wparam; - } - else - mcs.times[HIWORD(missed)]++; - - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0); - } - break; - - case ICON_ONLINE: - case ICON_AWAY: - case ICON_NA: - case ICON_OCC: - case ICON_DND: - case ICON_FREE: - case ICON_INVIS: - DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",1); - break; - } - - return 0; -} - - - -int ModeChange_mo(WPARAM wparam,LPARAM lparam) -{ - ACKDATA *ack; - int isetting=0; - - ack=(ACKDATA *)lparam; - - if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0; - - isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); - - switch(isetting){ - - case ID_STATUS_AWAY: - case ID_STATUS_DND: - case ID_STATUS_NA: - if(ehmissed==NULL) - { - ZeroMemory(&mcs,sizeof(mcs)); - CheckIfOnline(); - //ehmissed=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,LogStatus); - ehmissed=HookEvent(ME_CLIST_CONTACTICONCHANGED,Test); - } - break; - - default: - if(ehmissed!=NULL) - { - UnhookEvent(ehmissed); - ehmissed=NULL; - ShowMissed(); - ResetMissed(); - } - break; - } - - return 0; -} diff --git a/plugins/SeenPlugin/missed.cpp b/plugins/SeenPlugin/missed.cpp new file mode 100644 index 0000000000..179dd8ee4d --- /dev/null +++ b/plugins/SeenPlugin/missed.cpp @@ -0,0 +1,301 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/missed.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + +#include + + + +MISSEDCONTACTS mcs; +extern HANDLE ehmissed; +extern HINSTANCE hInstance; + + + +WPARAM IsUserMissed(WPARAM contact) +{ + int loop=0; + + for (;loopszSetting,"Status") || (strcmp(cws->szModule,"ICQ") && strcmp(cws->szModule,"MSN")) || (HANDLE)wparam==NULL) return 0; + + if(CallService(MS_IGNORE_ISIGNORED,wparam,IGNOREEVENT_USERONLINE)) + return 0; + + if(cws->value.wVal==ID_STATUS_OFFLINE) + { + if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==1) + { + mcs.times[mcs.count]++; + mcs.wpcontact[mcs.count++]=wparam; + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0); + } + + else if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==3) + mcs.times[HIWORD(IsUserMissed(wparam))]++; + + return 0; + } + + wpvar=IsUserMissed(wparam); + if(LOWORD(wpvar)) + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",3); + + else + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",1); + + return 0; +} + +*/ + +int Test(WPARAM wparam,LPARAM lparam) +{ + if(lparamICON_INVIS) + return 0; + + if(CallService(MS_IGNORE_ISIGNORED,wparam,IGNOREEVENT_USERONLINE)) + return 0; + + if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==2) + return 0; + + switch(lparam){ + + case ICON_OFFLINE: + if(DBGetContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0)==1) + { + WORD missed=IsUserMissed(wparam); + + if (!LOWORD(missed)) + { + mcs.times[mcs.count]=1; + mcs.wpcontact[mcs.count++]=wparam; + } + else + mcs.times[HIWORD(missed)]++; + + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",0); + } + break; + + case ICON_ONLINE: + case ICON_AWAY: + case ICON_NA: + case ICON_OCC: + case ICON_DND: + case ICON_FREE: + case ICON_INVIS: + DBWriteContactSettingByte((HANDLE)wparam,S_MOD,"Missed",1); + break; + } + + return 0; +} + + + +int ModeChange_mo(WPARAM wparam,LPARAM lparam) +{ + ACKDATA *ack; + int isetting=0; + + ack=(ACKDATA *)lparam; + + if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0; + + isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); + + switch(isetting){ + + case ID_STATUS_AWAY: + case ID_STATUS_DND: + case ID_STATUS_NA: + if(ehmissed==NULL) + { + ZeroMemory(&mcs,sizeof(mcs)); + CheckIfOnline(); + //ehmissed=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,LogStatus); + ehmissed=HookEvent(ME_CLIST_CONTACTICONCHANGED,Test); + } + break; + + default: + if(ehmissed!=NULL) + { + UnhookEvent(ehmissed); + ehmissed=NULL; + ShowMissed(); + ResetMissed(); + } + break; + } + + return 0; +} diff --git a/plugins/SeenPlugin/options.c b/plugins/SeenPlugin/options.c deleted file mode 100644 index daab1e8ee3..0000000000 --- a/plugins/SeenPlugin/options.c +++ /dev/null @@ -1,494 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/options.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - - - -extern HINSTANCE hInstance; -extern HANDLE ehuserinfo,hmenuitem,ehmissed_proto; -void BuildInfo(char *,char *,char *); -int BuildContactMenu(WPARAM,LPARAM); -int UserinfoInit(WPARAM,LPARAM); -int InitFileOutput(void); -void ShutdownFileOutput(void); -void InitMenuitem(void); -int ModeChange_mo(WPARAM,LPARAM); -int CheckIfOnline(void); -int ResetMissed(void); -static BOOL (WINAPI *pfnEnableThemeDialogTexture)(HANDLE, DWORD) = 0; - -INT_PTR CALLBACK OptsPopUpsDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - DBVARIANT dbv; - int i; - char szstamp[256]; - BOOL hasPopups; - switch(msg) - { - case WM_INITDIALOG:{ - if (hasPopups = (ServiceExists(MS_POPUP_QUERY) != 0)) - hasPopups = CallService(MS_POPUP_QUERY,PUQS_GETSTATUS,0); - TranslateDialogDefault(hdlg); - ShowWindow(GetDlgItem(hdlg,IDC_MISSPOPUP),hasPopups?SW_HIDE:SW_SHOW); - ShowWindow(GetDlgItem(hdlg,IDC_POPUPS),hasPopups?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hdlg,IDC_LABTEXT),hasPopups?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hdlg,IDC_LABTTITLE),hasPopups?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups?SW_SHOW:SW_HIDE); - CheckDlgButton(hdlg,IDC_POPUPS,DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)&hasPopups); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPS),hasPopups); - hasPopups = IsDlgButtonChecked(hdlg,IDC_POPUPS); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups); - for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { - DWORD sett; - COLORREF back, text; - sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); - sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[i-ID_STATUS_OFFLINE]); - GetColorsFromDWord(&back, &text, sett); - SendDlgItemMessage(hdlg,i,CPM_SETCOLOUR,0,back); - SendDlgItemMessage(hdlg,i+20,CPM_SETCOLOUR,0,text); - EnableWindow(GetDlgItem(hdlg,i),hasPopups); - EnableWindow(GetDlgItem(hdlg,i+20),hasPopups); - } - - SetDlgItemText(hdlg,IDC_POPUPSTAMP,!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP); - DBFreeVariant(&dbv); - SetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT); - DBFreeVariant(&dbv); - - } - break; //case WM_INITDIALOG - case WM_COMMAND: - if ((HIWORD(wparam)==BN_CLICKED || HIWORD(wparam)==EN_CHANGE) && GetFocus()==(HWND)lparam) - SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); - else if (HIWORD(wparam)==CPN_COLOURCHANGED){ - WORD idText, idBack; - POPUPDATAEX ppd = {0}; - DBVARIANT dbv = {0}; - DWORD temp; - if (LOWORD(wparam)>ID_STATUS_OUTTOLUNCH){ // we have clicked a text color - idText = wparam; idBack = wparam-20; - } else {idText = wparam+20; idBack = wparam;} - ppd.colorBack = SendDlgItemMessage(hdlg,idBack,CPM_GETCOLOUR,0,0); - ppd.colorText = SendDlgItemMessage(hdlg,idText,CPM_GETCOLOUR,0,0); - temp = GetDWordFromColors(ppd.colorBack,ppd.colorText); - GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,temp); - SendDlgItemMessage(hdlg,idBack,CPM_SETCOLOUR,0,ppd.colorBack); - SendDlgItemMessage(hdlg,idText,CPM_SETCOLOUR,0,ppd.colorText); - ppd.lchIcon = LoadSkinnedProtoIcon(NULL, idBack); - GetDlgItemText(hdlg,IDC_POPUPSTAMP,szstamp,255); - strncpy(ppd.lpzContactName,ParseString(szstamp,NULL,0),MAX_CONTACTNAME); - GetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,szstamp,255); - strncpy(ppd.lpzText,ParseString(szstamp,NULL,0),MAX_SECONDLINE); - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); - - SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); - } - if(HIWORD(wparam)==BN_CLICKED) - { - switch(LOWORD(wparam)) { - case IDC_POPUPS: - hasPopups = IsDlgButtonChecked(hdlg,IDC_POPUPS); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups); - EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups); - for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { - EnableWindow(GetDlgItem(hdlg,i),hasPopups); - EnableWindow(GetDlgItem(hdlg,i+20),hasPopups); - } - break; - case IDC_DEFAULTCOL: - for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { - DWORD sett; - COLORREF back, text; - sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); - sett = StatusColors15bits[i-ID_STATUS_OFFLINE]; - GetColorsFromDWord(&back, &text, sett); - SendDlgItemMessage(hdlg,i,CPM_SETCOLOUR,0,back); - SendDlgItemMessage(hdlg,i+20,CPM_SETCOLOUR,0,text); - } - break; - } - } - break; //case WM_COMMAND - - case WM_NOTIFY: - switch(((LPNMHDR)lparam)->idFrom) - { - case 0: - switch (((LPNMHDR)lparam)->code) - { - BYTE checkValue; - - case PSN_APPLY: - GetDlgItemText(hdlg,IDC_POPUPSTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"PopupStamp",szstamp); - GetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"PopupStampText",szstamp); - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_POPUPS); - if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"UsePopups",checkValue); - } - for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { - DWORD sett; - COLORREF back=0, text=0; - sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); - back = SendDlgItemMessage(hdlg,i,CPM_GETCOLOUR,0,0); - text = SendDlgItemMessage(hdlg,i+20,CPM_GETCOLOUR,0,0); - sett=GetDWordFromColors(back,text); - if (sett!=StatusColors15bits[i-ID_STATUS_OFFLINE]) - DBWriteContactSettingDword(NULL,S_MOD,szstamp,sett); - else DBDeleteContactSetting(NULL,S_MOD,szstamp); - } - - break; //case PSN_APPLY - } - break; //case 0 - } - break;//case WM_NOTIFY - - } - - return 0; -} - -INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - DBVARIANT dbv; - char szstamp[256]; - BYTE bchecked=0; - WPARAM wpsend=0; - - switch(msg) - { - case WM_INITDIALOG:{ - TranslateDialogDefault(hdlg); - - CheckDlgButton(hdlg,IDC_MENUITEM,DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)); - CheckDlgButton(hdlg,IDC_USERINFO,DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1)); - CheckDlgButton(hdlg,IDC_FILE,DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)); - CheckDlgButton(hdlg,IDC_HISTORY,DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0)); - CheckDlgButton(hdlg,IDC_IGNOREOFFLINE,DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)); - CheckDlgButton(hdlg,IDC_MISSEDONES,DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)); - CheckDlgButton(hdlg,IDC_SHOWICON,DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)); - CheckDlgButton(hdlg,IDC_COUNT,DBGetContactSettingByte(NULL,S_MOD,"MissedOnes_Count",0)); - CheckDlgButton(hdlg,IDC_IDLESUPPORT,DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1)); - - EnableWindow(GetDlgItem(hdlg,IDC_MENUSTAMP),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); - EnableWindow(GetDlgItem(hdlg,IDC_SHOWICON),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); - EnableWindow(GetDlgItem(hdlg,IDC_USERSTAMP),IsDlgButtonChecked(hdlg,IDC_USERINFO)); - EnableWindow(GetDlgItem(hdlg,IDC_FILESTAMP),IsDlgButtonChecked(hdlg,IDC_FILE)); - EnableWindow(GetDlgItem(hdlg,IDC_FILENAME),IsDlgButtonChecked(hdlg,IDC_FILE)); - EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSIZE),IsDlgButtonChecked(hdlg,IDC_HISTORY)); - EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSTAMP),IsDlgButtonChecked(hdlg,IDC_HISTORY)); - EnableWindow(GetDlgItem(hdlg,IDC_COUNT),IsDlgButtonChecked(hdlg,IDC_MISSEDONES)); - - SetDlgItemText(hdlg,IDC_MENUSTAMP,!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP); - DBFreeVariant(&dbv); - SetDlgItemText(hdlg,IDC_USERSTAMP,!DBGetContactSetting(NULL,S_MOD,"UserStamp",&dbv)?dbv.pszVal:DEFAULT_USERSTAMP); - DBFreeVariant(&dbv); - SetDlgItemText(hdlg,IDC_FILESTAMP,!DBGetContactSetting(NULL,S_MOD,"FileStamp",&dbv)?dbv.pszVal:DEFAULT_FILESTAMP); - DBFreeVariant(&dbv); - SetDlgItemText(hdlg,IDC_FILENAME,!DBGetContactSetting(NULL,S_MOD,"FileName",&dbv)?dbv.pszVal:DEFAULT_FILENAME); - DBFreeVariant(&dbv); - SetDlgItemInt(hdlg,IDC_HISTORYSIZE,DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10-1)-1,FALSE); - SetDlgItemText(hdlg,IDC_HISTORYSTAMP,!DBGetContactSetting(NULL,S_MOD,"HistoryStamp",&dbv)?dbv.pszVal:DEFAULT_HISTORYSTAMP); - DBFreeVariant(&dbv); - - // load protocol list - SetWindowLongPtr(GetDlgItem(hdlg,IDC_PROTOCOLLIST),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hdlg,IDC_PROTOCOLLIST),GWL_STYLE)|TVS_CHECKBOXES); - { - TVINSERTSTRUCT tvis; - int numberOfProtocols,i; - PROTOCOLDESCRIPTOR** protos; - char *protoName; - char *protoLabel; - - tvis.hParent=NULL; - tvis.hInsertAfter=TVI_LAST; - tvis.item.mask=TVIF_TEXT | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; - tvis.item.stateMask = TVIS_STATEIMAGEMASK; - - CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&numberOfProtocols,(LPARAM)&protos); - for (i=0; itype!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; - protoName = (char *)malloc(strlen(protos[i]->szName)+1); - strcpy(protoName,protos[i]->szName); -//debug(protoName); - protoLabel = (char *)malloc(MAXMODULELABELLENGTH+1); - CallProtoService(protoName,PS_GETNAME,MAXMODULELABELLENGTH,(LPARAM)protoLabel); -//debug(protoLabel); - tvis.item.pszText = protoLabel; - tvis.item.lParam = (LPARAM)protoName; - tvis.item.state = INDEXTOSTATEIMAGEMASK(IsWatchedProtocol(protoName)+1); - TreeView_InsertItem(GetDlgItem(hdlg,IDC_PROTOCOLLIST),&tvis); - free(protoLabel); - - } - } - } - break; //case WM_INITDIALOG - - case WM_COMMAND: - if ((HIWORD(wparam)==BN_CLICKED || HIWORD(wparam)==EN_CHANGE) && GetFocus()==(HWND)lparam) - if (LOWORD(wparam)!=IDC_VARIABLES)SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); - - if(HIWORD(wparam)==BN_CLICKED) - { - switch(LOWORD(wparam)) { - case IDC_MENUITEM: - EnableWindow(GetDlgItem(hdlg,IDC_MENUSTAMP),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); - EnableWindow(GetDlgItem(hdlg,IDC_SHOWICON),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); - break; - case IDC_USERINFO: - EnableWindow(GetDlgItem(hdlg,IDC_USERSTAMP),IsDlgButtonChecked(hdlg,IDC_USERINFO)); - break; - case IDC_FILE: - EnableWindow(GetDlgItem(hdlg,IDC_FILESTAMP),IsDlgButtonChecked(hdlg,IDC_FILE)); - EnableWindow(GetDlgItem(hdlg,IDC_FILENAME),IsDlgButtonChecked(hdlg,IDC_FILE)); - break; - case IDC_HISTORY: - EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSTAMP),IsDlgButtonChecked(hdlg,IDC_HISTORY)); - EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSIZE),IsDlgButtonChecked(hdlg,IDC_HISTORY)); - break; - case IDC_MISSEDONES: - EnableWindow(GetDlgItem(hdlg,IDC_COUNT),IsDlgButtonChecked(hdlg,IDC_MISSEDONES)); - break; - } - } - - if (LOWORD(wparam)==IDC_VARIABLES) - { - char szout[2048]=""; - wsprintf(szout,VARIABLE_LIST); - MessageBox(NULL,szout,Translate("Last Seen Variables"),MB_OK|MB_TOPMOST); - } - - break; //case WM_COMMAND - - case WM_NOTIFY: - switch(((LPNMHDR)lparam)->idFrom) - { - case 0: - switch (((LPNMHDR)lparam)->code) - { - BYTE checkValue; - - case PSN_APPLY: - - GetDlgItemText(hdlg,IDC_MENUSTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"MenuStamp",szstamp); - - GetDlgItemText(hdlg,IDC_USERSTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"UserStamp",szstamp); - - GetDlgItemText(hdlg,IDC_FILESTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"FileStamp",szstamp); - - GetDlgItemText(hdlg,IDC_FILENAME,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"FileName",szstamp); - - GetDlgItemText(hdlg,IDC_HISTORYSTAMP,szstamp,256); - DBWriteContactSettingString(NULL,S_MOD,"HistoryStamp",szstamp); - - DBWriteContactSettingWord(NULL,S_MOD,"HistoryMax",(WORD)(GetDlgItemInt(hdlg,IDC_HISTORYSIZE,NULL,FALSE)+1)); - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_MENUITEM); - if (DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"MenuItem",checkValue); - if(hmenuitem==NULL && checkValue) { - InitMenuitem(); - } - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_USERINFO); - if (DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"UserinfoTab",checkValue); - if(checkValue) { - ehuserinfo=HookEvent(ME_USERINFO_INITIALISE,UserinfoInit); - } else { - UnhookEvent(ehuserinfo); - } - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_FILE); - if (DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"FileOutput",checkValue); - if(checkValue) { - InitFileOutput(); - } - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_HISTORY); - if (DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"KeepHistory",checkValue); - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_IGNOREOFFLINE); - if (DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"IgnoreOffline",checkValue); - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_MISSEDONES); - if (DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"MissedOnes",checkValue); - if(checkValue) { - ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); - } else { - UnhookEvent(ehmissed_proto); - } - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_SHOWICON); - if (DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"ShowIcon",checkValue); - } - - checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_COUNT); - if (DBGetContactSettingByte(NULL,S_MOD,"MissedOnes_Count",0) != checkValue) { - DBWriteContactSettingByte(NULL,S_MOD,"MissedOnes_Count",checkValue); - } - - includeIdle = (BYTE)IsDlgButtonChecked(hdlg,IDC_IDLESUPPORT); - if (DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1) != includeIdle) { - DBWriteContactSettingByte(NULL,S_MOD,"IdleSupport",(BYTE)includeIdle); - } - - // save protocol list - { - HWND hwndTreeView = GetDlgItem(hdlg,IDC_PROTOCOLLIST); - HTREEITEM hItem; - TVITEM tvItem; - char *watchedProtocols; - char *protocol; - int size=1; - - watchedProtocols = (char *)malloc(sizeof(char)); - *watchedProtocols = '\0'; - hItem = TreeView_GetRoot(hwndTreeView); - tvItem.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; - tvItem.stateMask = TVIS_STATEIMAGEMASK; - - while (hItem != NULL) { - tvItem.hItem = hItem; - TreeView_GetItem(hwndTreeView, &tvItem); - protocol = (char*)tvItem.lParam; - if ((BOOL)(tvItem.state >> 12) -1) { - size = (size + (int)_tcslen(protocol)+2) * sizeof(char); - watchedProtocols = (char *)realloc(watchedProtocols, size); - strcat(watchedProtocols, protocol); - strcat(watchedProtocols, " "); - } - hItem = TreeView_GetNextSibling(hwndTreeView, hItem); - } - DBWriteContactSettingString(NULL,S_MOD,"WatchedProtocols",watchedProtocols); - free(watchedProtocols); - } - - break; //case PSN_APPLY - } - break; //case 0 - - case IDC_PROTOCOLLIST: - switch (((LPNMHDR)lparam)->code) - { - case NM_CLICK: - { - HWND hTree=((LPNMHDR)lparam)->hwndFrom; - TVHITTESTINFO hti; - HTREEITEM hItem; - - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(hTree,&hti.pt); - if(hItem=TreeView_HitTest(hTree,&hti)) - { - if (hti.flags & TVHT_ONITEM) - TreeView_SelectItem(hTree,hItem); - if (hti.flags & TVHT_ONITEMSTATEICON) - SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); - - } - } - break; - } - break; //case IDC_PROTOCOLLIST - } - break;//case WM_NOTIFY - - case WM_DESTROY: - // free protocol list - { - HWND hwndTreeView = GetDlgItem(hdlg,IDC_PROTOCOLLIST); - HTREEITEM hItem; - TVITEM tvItem; - - hItem = TreeView_GetRoot(hwndTreeView); - tvItem.mask = TVIF_HANDLE | TVIF_PARAM; - - while (hItem != NULL) { - tvItem.hItem = hItem; - TreeView_GetItem(hwndTreeView, &tvItem); - free((void *)tvItem.lParam); - hItem = TreeView_GetNextSibling(hwndTreeView, hItem); - } - } - break; - - } - - return 0; -} - -int OptionsInit(WPARAM wparam,LPARAM lparam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - - if(IsWinVerXPPlus()) { - HMODULE hUxTheme = GetModuleHandle(_T("uxtheme.dll")); - if (hUxTheme) - pfnEnableThemeDialogTexture = (BOOL (WINAPI *)(HANDLE, DWORD))GetProcAddress(hUxTheme, "EnableThemeDialogTexture"); - } - - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInstance; - odp.flags = ODPF_BOLDGROUPS; - odp.pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS); - odp.pszGroup = LPGEN("Services"); - odp.pszTitle = LPGEN("Last seen"); - odp.pfnDlgProc = OptsSettingsDlgProc; - Options_AddPage(wparam,&odp); - - if (ServiceExists(MS_POPUP_ADDPOPUP)) { - odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUPS); - odp.pszGroup = LPGEN("PopUps"); - odp.pszTitle = LPGEN("Last seen"); - odp.pfnDlgProc = OptsPopUpsDlgProc; - Options_AddPage(wparam,&odp); - } - return 0; -} diff --git a/plugins/SeenPlugin/options.cpp b/plugins/SeenPlugin/options.cpp new file mode 100644 index 0000000000..daab1e8ee3 --- /dev/null +++ b/plugins/SeenPlugin/options.cpp @@ -0,0 +1,494 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/options.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + + + +extern HINSTANCE hInstance; +extern HANDLE ehuserinfo,hmenuitem,ehmissed_proto; +void BuildInfo(char *,char *,char *); +int BuildContactMenu(WPARAM,LPARAM); +int UserinfoInit(WPARAM,LPARAM); +int InitFileOutput(void); +void ShutdownFileOutput(void); +void InitMenuitem(void); +int ModeChange_mo(WPARAM,LPARAM); +int CheckIfOnline(void); +int ResetMissed(void); +static BOOL (WINAPI *pfnEnableThemeDialogTexture)(HANDLE, DWORD) = 0; + +INT_PTR CALLBACK OptsPopUpsDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + DBVARIANT dbv; + int i; + char szstamp[256]; + BOOL hasPopups; + switch(msg) + { + case WM_INITDIALOG:{ + if (hasPopups = (ServiceExists(MS_POPUP_QUERY) != 0)) + hasPopups = CallService(MS_POPUP_QUERY,PUQS_GETSTATUS,0); + TranslateDialogDefault(hdlg); + ShowWindow(GetDlgItem(hdlg,IDC_MISSPOPUP),hasPopups?SW_HIDE:SW_SHOW); + ShowWindow(GetDlgItem(hdlg,IDC_POPUPS),hasPopups?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hdlg,IDC_LABTEXT),hasPopups?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hdlg,IDC_LABTTITLE),hasPopups?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups?SW_SHOW:SW_HIDE); + CheckDlgButton(hdlg,IDC_POPUPS,DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)&hasPopups); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPS),hasPopups); + hasPopups = IsDlgButtonChecked(hdlg,IDC_POPUPS); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups); + for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { + DWORD sett; + COLORREF back, text; + sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); + sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[i-ID_STATUS_OFFLINE]); + GetColorsFromDWord(&back, &text, sett); + SendDlgItemMessage(hdlg,i,CPM_SETCOLOUR,0,back); + SendDlgItemMessage(hdlg,i+20,CPM_SETCOLOUR,0,text); + EnableWindow(GetDlgItem(hdlg,i),hasPopups); + EnableWindow(GetDlgItem(hdlg,i+20),hasPopups); + } + + SetDlgItemText(hdlg,IDC_POPUPSTAMP,!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP); + DBFreeVariant(&dbv); + SetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT); + DBFreeVariant(&dbv); + + } + break; //case WM_INITDIALOG + case WM_COMMAND: + if ((HIWORD(wparam)==BN_CLICKED || HIWORD(wparam)==EN_CHANGE) && GetFocus()==(HWND)lparam) + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + else if (HIWORD(wparam)==CPN_COLOURCHANGED){ + WORD idText, idBack; + POPUPDATAEX ppd = {0}; + DBVARIANT dbv = {0}; + DWORD temp; + if (LOWORD(wparam)>ID_STATUS_OUTTOLUNCH){ // we have clicked a text color + idText = wparam; idBack = wparam-20; + } else {idText = wparam+20; idBack = wparam;} + ppd.colorBack = SendDlgItemMessage(hdlg,idBack,CPM_GETCOLOUR,0,0); + ppd.colorText = SendDlgItemMessage(hdlg,idText,CPM_GETCOLOUR,0,0); + temp = GetDWordFromColors(ppd.colorBack,ppd.colorText); + GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,temp); + SendDlgItemMessage(hdlg,idBack,CPM_SETCOLOUR,0,ppd.colorBack); + SendDlgItemMessage(hdlg,idText,CPM_SETCOLOUR,0,ppd.colorText); + ppd.lchIcon = LoadSkinnedProtoIcon(NULL, idBack); + GetDlgItemText(hdlg,IDC_POPUPSTAMP,szstamp,255); + strncpy(ppd.lpzContactName,ParseString(szstamp,NULL,0),MAX_CONTACTNAME); + GetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,szstamp,255); + strncpy(ppd.lpzText,ParseString(szstamp,NULL,0),MAX_SECONDLINE); + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); + + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + } + if(HIWORD(wparam)==BN_CLICKED) + { + switch(LOWORD(wparam)) { + case IDC_POPUPS: + hasPopups = IsDlgButtonChecked(hdlg,IDC_POPUPS); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMP),hasPopups); + EnableWindow(GetDlgItem(hdlg,IDC_POPUPSTAMPTEXT),hasPopups); + for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { + EnableWindow(GetDlgItem(hdlg,i),hasPopups); + EnableWindow(GetDlgItem(hdlg,i+20),hasPopups); + } + break; + case IDC_DEFAULTCOL: + for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { + DWORD sett; + COLORREF back, text; + sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); + sett = StatusColors15bits[i-ID_STATUS_OFFLINE]; + GetColorsFromDWord(&back, &text, sett); + SendDlgItemMessage(hdlg,i,CPM_SETCOLOUR,0,back); + SendDlgItemMessage(hdlg,i+20,CPM_SETCOLOUR,0,text); + } + break; + } + } + break; //case WM_COMMAND + + case WM_NOTIFY: + switch(((LPNMHDR)lparam)->idFrom) + { + case 0: + switch (((LPNMHDR)lparam)->code) + { + BYTE checkValue; + + case PSN_APPLY: + GetDlgItemText(hdlg,IDC_POPUPSTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"PopupStamp",szstamp); + GetDlgItemText(hdlg,IDC_POPUPSTAMPTEXT,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"PopupStampText",szstamp); + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_POPUPS); + if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"UsePopups",checkValue); + } + for (i=ID_STATUS_OFFLINE;i<=ID_STATUS_OUTTOLUNCH;i++) { + DWORD sett; + COLORREF back=0, text=0; + sprintf(szstamp, "Col_%d",i-ID_STATUS_OFFLINE); + back = SendDlgItemMessage(hdlg,i,CPM_GETCOLOUR,0,0); + text = SendDlgItemMessage(hdlg,i+20,CPM_GETCOLOUR,0,0); + sett=GetDWordFromColors(back,text); + if (sett!=StatusColors15bits[i-ID_STATUS_OFFLINE]) + DBWriteContactSettingDword(NULL,S_MOD,szstamp,sett); + else DBDeleteContactSetting(NULL,S_MOD,szstamp); + } + + break; //case PSN_APPLY + } + break; //case 0 + } + break;//case WM_NOTIFY + + } + + return 0; +} + +INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + DBVARIANT dbv; + char szstamp[256]; + BYTE bchecked=0; + WPARAM wpsend=0; + + switch(msg) + { + case WM_INITDIALOG:{ + TranslateDialogDefault(hdlg); + + CheckDlgButton(hdlg,IDC_MENUITEM,DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)); + CheckDlgButton(hdlg,IDC_USERINFO,DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1)); + CheckDlgButton(hdlg,IDC_FILE,DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)); + CheckDlgButton(hdlg,IDC_HISTORY,DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0)); + CheckDlgButton(hdlg,IDC_IGNOREOFFLINE,DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)); + CheckDlgButton(hdlg,IDC_MISSEDONES,DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0)); + CheckDlgButton(hdlg,IDC_SHOWICON,DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)); + CheckDlgButton(hdlg,IDC_COUNT,DBGetContactSettingByte(NULL,S_MOD,"MissedOnes_Count",0)); + CheckDlgButton(hdlg,IDC_IDLESUPPORT,DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1)); + + EnableWindow(GetDlgItem(hdlg,IDC_MENUSTAMP),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); + EnableWindow(GetDlgItem(hdlg,IDC_SHOWICON),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); + EnableWindow(GetDlgItem(hdlg,IDC_USERSTAMP),IsDlgButtonChecked(hdlg,IDC_USERINFO)); + EnableWindow(GetDlgItem(hdlg,IDC_FILESTAMP),IsDlgButtonChecked(hdlg,IDC_FILE)); + EnableWindow(GetDlgItem(hdlg,IDC_FILENAME),IsDlgButtonChecked(hdlg,IDC_FILE)); + EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSIZE),IsDlgButtonChecked(hdlg,IDC_HISTORY)); + EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSTAMP),IsDlgButtonChecked(hdlg,IDC_HISTORY)); + EnableWindow(GetDlgItem(hdlg,IDC_COUNT),IsDlgButtonChecked(hdlg,IDC_MISSEDONES)); + + SetDlgItemText(hdlg,IDC_MENUSTAMP,!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP); + DBFreeVariant(&dbv); + SetDlgItemText(hdlg,IDC_USERSTAMP,!DBGetContactSetting(NULL,S_MOD,"UserStamp",&dbv)?dbv.pszVal:DEFAULT_USERSTAMP); + DBFreeVariant(&dbv); + SetDlgItemText(hdlg,IDC_FILESTAMP,!DBGetContactSetting(NULL,S_MOD,"FileStamp",&dbv)?dbv.pszVal:DEFAULT_FILESTAMP); + DBFreeVariant(&dbv); + SetDlgItemText(hdlg,IDC_FILENAME,!DBGetContactSetting(NULL,S_MOD,"FileName",&dbv)?dbv.pszVal:DEFAULT_FILENAME); + DBFreeVariant(&dbv); + SetDlgItemInt(hdlg,IDC_HISTORYSIZE,DBGetContactSettingWord(NULL,S_MOD,"HistoryMax",10-1)-1,FALSE); + SetDlgItemText(hdlg,IDC_HISTORYSTAMP,!DBGetContactSetting(NULL,S_MOD,"HistoryStamp",&dbv)?dbv.pszVal:DEFAULT_HISTORYSTAMP); + DBFreeVariant(&dbv); + + // load protocol list + SetWindowLongPtr(GetDlgItem(hdlg,IDC_PROTOCOLLIST),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hdlg,IDC_PROTOCOLLIST),GWL_STYLE)|TVS_CHECKBOXES); + { + TVINSERTSTRUCT tvis; + int numberOfProtocols,i; + PROTOCOLDESCRIPTOR** protos; + char *protoName; + char *protoLabel; + + tvis.hParent=NULL; + tvis.hInsertAfter=TVI_LAST; + tvis.item.mask=TVIF_TEXT | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; + tvis.item.stateMask = TVIS_STATEIMAGEMASK; + + CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&numberOfProtocols,(LPARAM)&protos); + for (i=0; itype!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; + protoName = (char *)malloc(strlen(protos[i]->szName)+1); + strcpy(protoName,protos[i]->szName); +//debug(protoName); + protoLabel = (char *)malloc(MAXMODULELABELLENGTH+1); + CallProtoService(protoName,PS_GETNAME,MAXMODULELABELLENGTH,(LPARAM)protoLabel); +//debug(protoLabel); + tvis.item.pszText = protoLabel; + tvis.item.lParam = (LPARAM)protoName; + tvis.item.state = INDEXTOSTATEIMAGEMASK(IsWatchedProtocol(protoName)+1); + TreeView_InsertItem(GetDlgItem(hdlg,IDC_PROTOCOLLIST),&tvis); + free(protoLabel); + + } + } + } + break; //case WM_INITDIALOG + + case WM_COMMAND: + if ((HIWORD(wparam)==BN_CLICKED || HIWORD(wparam)==EN_CHANGE) && GetFocus()==(HWND)lparam) + if (LOWORD(wparam)!=IDC_VARIABLES)SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + + if(HIWORD(wparam)==BN_CLICKED) + { + switch(LOWORD(wparam)) { + case IDC_MENUITEM: + EnableWindow(GetDlgItem(hdlg,IDC_MENUSTAMP),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); + EnableWindow(GetDlgItem(hdlg,IDC_SHOWICON),IsDlgButtonChecked(hdlg,IDC_MENUITEM)); + break; + case IDC_USERINFO: + EnableWindow(GetDlgItem(hdlg,IDC_USERSTAMP),IsDlgButtonChecked(hdlg,IDC_USERINFO)); + break; + case IDC_FILE: + EnableWindow(GetDlgItem(hdlg,IDC_FILESTAMP),IsDlgButtonChecked(hdlg,IDC_FILE)); + EnableWindow(GetDlgItem(hdlg,IDC_FILENAME),IsDlgButtonChecked(hdlg,IDC_FILE)); + break; + case IDC_HISTORY: + EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSTAMP),IsDlgButtonChecked(hdlg,IDC_HISTORY)); + EnableWindow(GetDlgItem(hdlg,IDC_HISTORYSIZE),IsDlgButtonChecked(hdlg,IDC_HISTORY)); + break; + case IDC_MISSEDONES: + EnableWindow(GetDlgItem(hdlg,IDC_COUNT),IsDlgButtonChecked(hdlg,IDC_MISSEDONES)); + break; + } + } + + if (LOWORD(wparam)==IDC_VARIABLES) + { + char szout[2048]=""; + wsprintf(szout,VARIABLE_LIST); + MessageBox(NULL,szout,Translate("Last Seen Variables"),MB_OK|MB_TOPMOST); + } + + break; //case WM_COMMAND + + case WM_NOTIFY: + switch(((LPNMHDR)lparam)->idFrom) + { + case 0: + switch (((LPNMHDR)lparam)->code) + { + BYTE checkValue; + + case PSN_APPLY: + + GetDlgItemText(hdlg,IDC_MENUSTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"MenuStamp",szstamp); + + GetDlgItemText(hdlg,IDC_USERSTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"UserStamp",szstamp); + + GetDlgItemText(hdlg,IDC_FILESTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"FileStamp",szstamp); + + GetDlgItemText(hdlg,IDC_FILENAME,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"FileName",szstamp); + + GetDlgItemText(hdlg,IDC_HISTORYSTAMP,szstamp,256); + DBWriteContactSettingString(NULL,S_MOD,"HistoryStamp",szstamp); + + DBWriteContactSettingWord(NULL,S_MOD,"HistoryMax",(WORD)(GetDlgItemInt(hdlg,IDC_HISTORYSIZE,NULL,FALSE)+1)); + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_MENUITEM); + if (DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"MenuItem",checkValue); + if(hmenuitem==NULL && checkValue) { + InitMenuitem(); + } + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_USERINFO); + if (DBGetContactSettingByte(NULL,S_MOD,"UserinfoTab",1) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"UserinfoTab",checkValue); + if(checkValue) { + ehuserinfo=HookEvent(ME_USERINFO_INITIALISE,UserinfoInit); + } else { + UnhookEvent(ehuserinfo); + } + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_FILE); + if (DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"FileOutput",checkValue); + if(checkValue) { + InitFileOutput(); + } + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_HISTORY); + if (DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"KeepHistory",checkValue); + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_IGNOREOFFLINE); + if (DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"IgnoreOffline",checkValue); + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_MISSEDONES); + if (DBGetContactSettingByte(NULL,S_MOD,"MissedOnes",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"MissedOnes",checkValue); + if(checkValue) { + ehmissed_proto=HookEvent(ME_PROTO_ACK,ModeChange_mo); + } else { + UnhookEvent(ehmissed_proto); + } + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_SHOWICON); + if (DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"ShowIcon",checkValue); + } + + checkValue = (BYTE)IsDlgButtonChecked(hdlg,IDC_COUNT); + if (DBGetContactSettingByte(NULL,S_MOD,"MissedOnes_Count",0) != checkValue) { + DBWriteContactSettingByte(NULL,S_MOD,"MissedOnes_Count",checkValue); + } + + includeIdle = (BYTE)IsDlgButtonChecked(hdlg,IDC_IDLESUPPORT); + if (DBGetContactSettingByte(NULL,S_MOD,"IdleSupport",1) != includeIdle) { + DBWriteContactSettingByte(NULL,S_MOD,"IdleSupport",(BYTE)includeIdle); + } + + // save protocol list + { + HWND hwndTreeView = GetDlgItem(hdlg,IDC_PROTOCOLLIST); + HTREEITEM hItem; + TVITEM tvItem; + char *watchedProtocols; + char *protocol; + int size=1; + + watchedProtocols = (char *)malloc(sizeof(char)); + *watchedProtocols = '\0'; + hItem = TreeView_GetRoot(hwndTreeView); + tvItem.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; + tvItem.stateMask = TVIS_STATEIMAGEMASK; + + while (hItem != NULL) { + tvItem.hItem = hItem; + TreeView_GetItem(hwndTreeView, &tvItem); + protocol = (char*)tvItem.lParam; + if ((BOOL)(tvItem.state >> 12) -1) { + size = (size + (int)_tcslen(protocol)+2) * sizeof(char); + watchedProtocols = (char *)realloc(watchedProtocols, size); + strcat(watchedProtocols, protocol); + strcat(watchedProtocols, " "); + } + hItem = TreeView_GetNextSibling(hwndTreeView, hItem); + } + DBWriteContactSettingString(NULL,S_MOD,"WatchedProtocols",watchedProtocols); + free(watchedProtocols); + } + + break; //case PSN_APPLY + } + break; //case 0 + + case IDC_PROTOCOLLIST: + switch (((LPNMHDR)lparam)->code) + { + case NM_CLICK: + { + HWND hTree=((LPNMHDR)lparam)->hwndFrom; + TVHITTESTINFO hti; + HTREEITEM hItem; + + hti.pt.x=(short)LOWORD(GetMessagePos()); + hti.pt.y=(short)HIWORD(GetMessagePos()); + ScreenToClient(hTree,&hti.pt); + if(hItem=TreeView_HitTest(hTree,&hti)) + { + if (hti.flags & TVHT_ONITEM) + TreeView_SelectItem(hTree,hItem); + if (hti.flags & TVHT_ONITEMSTATEICON) + SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); + + } + } + break; + } + break; //case IDC_PROTOCOLLIST + } + break;//case WM_NOTIFY + + case WM_DESTROY: + // free protocol list + { + HWND hwndTreeView = GetDlgItem(hdlg,IDC_PROTOCOLLIST); + HTREEITEM hItem; + TVITEM tvItem; + + hItem = TreeView_GetRoot(hwndTreeView); + tvItem.mask = TVIF_HANDLE | TVIF_PARAM; + + while (hItem != NULL) { + tvItem.hItem = hItem; + TreeView_GetItem(hwndTreeView, &tvItem); + free((void *)tvItem.lParam); + hItem = TreeView_GetNextSibling(hwndTreeView, hItem); + } + } + break; + + } + + return 0; +} + +int OptionsInit(WPARAM wparam,LPARAM lparam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + + if(IsWinVerXPPlus()) { + HMODULE hUxTheme = GetModuleHandle(_T("uxtheme.dll")); + if (hUxTheme) + pfnEnableThemeDialogTexture = (BOOL (WINAPI *)(HANDLE, DWORD))GetProcAddress(hUxTheme, "EnableThemeDialogTexture"); + } + + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInstance; + odp.flags = ODPF_BOLDGROUPS; + odp.pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS); + odp.pszGroup = LPGEN("Services"); + odp.pszTitle = LPGEN("Last seen"); + odp.pfnDlgProc = OptsSettingsDlgProc; + Options_AddPage(wparam,&odp); + + if (ServiceExists(MS_POPUP_ADDPOPUP)) { + odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUPS); + odp.pszGroup = LPGEN("PopUps"); + odp.pszTitle = LPGEN("Last seen"); + odp.pfnDlgProc = OptsPopUpsDlgProc; + Options_AddPage(wparam,&odp); + } + return 0; +} diff --git a/plugins/SeenPlugin/userinfo.c b/plugins/SeenPlugin/userinfo.c deleted file mode 100644 index 442860bb86..0000000000 --- a/plugins/SeenPlugin/userinfo.c +++ /dev/null @@ -1,95 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/userinfo.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" - - - -WNDPROC MainProc; - - - -extern HINSTANCE hInstance; -extern DWORD dwmirver; - - - -BOOL CALLBACK EditProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg){ - case WM_SETCURSOR: - SetCursor(LoadCursor(NULL,IDC_ARROW)); - return 1; - - default: - break; - } - return CallWindowProc(MainProc,hdlg,msg,wparam,lparam); -} - - - -INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - char *szout; - DBVARIANT dbv; - - switch(msg){ - - case WM_INITDIALOG: - MainProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hdlg,IDC_INFOTEXT),GWLP_WNDPROC,(LONG)EditProc); - szout=strdup(ParseString((!DBGetContactSetting(NULL,S_MOD,"UserStamp",&dbv)?dbv.pszVal:DEFAULT_USERSTAMP),(HANDLE)lparam,0)); - SetDlgItemText(hdlg,IDC_INFOTEXT,szout); - if (!strcmp(szout,Translate(""))) - EnableWindow(GetDlgItem(hdlg,IDC_INFOTEXT),FALSE); - free(szout); - DBFreeVariant(&dbv); - break; - - case WM_COMMAND: - if(HIWORD(wparam)==EN_SETFOCUS) - SetFocus(GetParent(hdlg)); - break; - } - - return 0; -} - - - -int UserinfoInit(WPARAM wparam,LPARAM lparam) -{ - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,lparam,0); - if (IsWatchedProtocol(proto)) { - OPTIONSDIALOGPAGE uip; - ZeroMemory(&uip,sizeof(uip)); - uip.cbSize=sizeof(uip); - uip.hInstance=hInstance; - uip.pszTemplate=MAKEINTRESOURCE(IDD_USERINFO); - uip.pszTitle="Last seen"; - uip.pfnDlgProc=UserinfoDlgProc; - UserInfo_AddPage(wparam, &uip); - } - return 0; -} diff --git a/plugins/SeenPlugin/userinfo.cpp b/plugins/SeenPlugin/userinfo.cpp new file mode 100644 index 0000000000..442860bb86 --- /dev/null +++ b/plugins/SeenPlugin/userinfo.cpp @@ -0,0 +1,95 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/userinfo.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" + + + +WNDPROC MainProc; + + + +extern HINSTANCE hInstance; +extern DWORD dwmirver; + + + +BOOL CALLBACK EditProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg){ + case WM_SETCURSOR: + SetCursor(LoadCursor(NULL,IDC_ARROW)); + return 1; + + default: + break; + } + return CallWindowProc(MainProc,hdlg,msg,wparam,lparam); +} + + + +INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + char *szout; + DBVARIANT dbv; + + switch(msg){ + + case WM_INITDIALOG: + MainProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hdlg,IDC_INFOTEXT),GWLP_WNDPROC,(LONG)EditProc); + szout=strdup(ParseString((!DBGetContactSetting(NULL,S_MOD,"UserStamp",&dbv)?dbv.pszVal:DEFAULT_USERSTAMP),(HANDLE)lparam,0)); + SetDlgItemText(hdlg,IDC_INFOTEXT,szout); + if (!strcmp(szout,Translate(""))) + EnableWindow(GetDlgItem(hdlg,IDC_INFOTEXT),FALSE); + free(szout); + DBFreeVariant(&dbv); + break; + + case WM_COMMAND: + if(HIWORD(wparam)==EN_SETFOCUS) + SetFocus(GetParent(hdlg)); + break; + } + + return 0; +} + + + +int UserinfoInit(WPARAM wparam,LPARAM lparam) +{ + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,lparam,0); + if (IsWatchedProtocol(proto)) { + OPTIONSDIALOGPAGE uip; + ZeroMemory(&uip,sizeof(uip)); + uip.cbSize=sizeof(uip); + uip.hInstance=hInstance; + uip.pszTemplate=MAKEINTRESOURCE(IDD_USERINFO); + uip.pszTitle="Last seen"; + uip.pfnDlgProc=UserinfoDlgProc; + UserInfo_AddPage(wparam, &uip); + } + return 0; +} diff --git a/plugins/SeenPlugin/utils.c b/plugins/SeenPlugin/utils.c deleted file mode 100644 index 4d0e64d00c..0000000000 --- a/plugins/SeenPlugin/utils.c +++ /dev/null @@ -1,924 +0,0 @@ -/* -"Last Seen mod" plugin for Miranda IM -Copyright ( C ) 2002-03 micron-x -Copyright ( C ) 2005-07 Y.B. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or ( at your option ) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/utils.c $ -Revision : $Rev: 1570 $ -Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ -Last change by : $Author: y_b $ -*/ -#include "seen.h" -#include -#include - - -void FileWrite(HANDLE); -void HistoryWrite(HANDLE hcontact); -//void SetOffline(void); -void ShowHistory(HANDLE hContact, BYTE isAlert); - -char * courProtoName = 0; - -//copied from ..\..\miranda32\protocols\protocols\protocols.c -PROTOCOLDESCRIPTOR* Proto_IsProtocolLoaded(const char* szProto) -{ - return (PROTOCOLDESCRIPTOR*) CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)szProto); -} - - -/* -Returns true if the protocols is to be monitored -*/ -int IsWatchedProtocol(const char* szProto) -{ - DBVARIANT dbv; - char *szProtoPointer, *szWatched; - int iProtoLen, iWatchedLen; - int retval = 0; - PROTOCOLDESCRIPTOR *pd; - - if (szProto == NULL) - return 0; - - pd=Proto_IsProtocolLoaded(szProto); - if (pd==NULL || pd->type!=PROTOTYPE_PROTOCOL || CallProtoService(pd->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) - return 0; - - iProtoLen = (int)_tcslen(szProto); - if(DBGetContactSetting(NULL, S_MOD, "WatchedProtocols", &dbv)) - szWatched = DEFAULT_WATCHEDPROTOCOLS; - else - szWatched = dbv.pszVal; - iWatchedLen = (int)_tcslen(szWatched); - - if (*szWatched == '\0') - { - retval=1; //empty string: all protocols are watched - } - else - { - char sTemp [MAXMODULELABELLENGTH+1]=""; - strcat(sTemp,szProto); - strcat(sTemp," "); - szProtoPointer = strstr(szWatched, sTemp); - if (szProtoPointer == NULL) - retval=0; - else - retval=1; - } - - DBFreeVariant(&dbv); - return retval; -} - -BOOL isYahoo(char * protoname){ - if (protoname) { - char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (pszUniqueSetting){ - return (!strcmp(pszUniqueSetting,"yahoo_id")); - } } - return FALSE; -} -BOOL isJabber(char * protoname){ - if (protoname) { - char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (pszUniqueSetting){ - return (!strcmp(pszUniqueSetting,"jid")); - } } - return FALSE; -} -BOOL isICQ(char * protoname){ - if (protoname) { - char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (pszUniqueSetting){ - return (!strcmp(pszUniqueSetting,"UIN")); - } } - return FALSE; -} -BOOL isMSN(char * protoname){ - if (protoname) { - char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (pszUniqueSetting){ - return (!strcmp(pszUniqueSetting,"e-mail")); - } } - return FALSE; -} - -DWORD isSeen(HANDLE hcontact, SYSTEMTIME *st){ - DWORD res = 0; - FILETIME ft; - ULONGLONG ll; - res = DBGetContactSettingDword(hcontact,S_MOD,"seenTS",0); - if (res){ - if (st) { - ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,res,0), 10000000) + NUM100NANOSEC; - ft.dwLowDateTime = (DWORD)ll; - ft.dwHighDateTime = (DWORD)(ll >> 32); - FileTimeToSystemTime(&ft, st); - } - return res; - } else { - SYSTEMTIME lst; - ZeroMemory(&lst,sizeof(lst)); - if (lst.wYear = DBGetContactSettingWord(hcontact,S_MOD,"Year",0)) { - if (lst.wMonth = DBGetContactSettingWord(hcontact,S_MOD,"Month",0)) { - if (lst.wDay = DBGetContactSettingWord(hcontact,S_MOD,"Day",0)) { - lst.wDayOfWeek = DBGetContactSettingWord(hcontact,S_MOD,"WeekDay",0); - lst.wHour = DBGetContactSettingWord(hcontact,S_MOD,"Hours",0); - lst.wMinute = DBGetContactSettingWord(hcontact,S_MOD,"Minutes",0); - lst.wSecond = DBGetContactSettingWord(hcontact,S_MOD,"Seconds",0); - if (SystemTimeToFileTime(&lst,&ft)) { - ll = ((LONGLONG)ft.dwHighDateTime<<32)|((LONGLONG)ft.dwLowDateTime); - ll -= NUM100NANOSEC; - ll /= 10000000; - //perform LOCALTOTIMESTAMP - res = (DWORD)ll - CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,0,0); - //nevel look for Year/Month/Day/Hour/Minute/Second again - DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",res); - } - } } } - if (st) CopyMemory (st, &lst, sizeof (SYSTEMTIME)); - } - return res; -} - -char *ParseString(char *szstring,HANDLE hcontact,BYTE isfile) -{ -#define MAXSIZE 1024 - static char sztemp[MAXSIZE+1]; - int sztemplen = 0; - char szdbsetting[128]=""; - char *charPtr; - UINT loop=0; - int isetting=0; - DWORD dwsetting=0; - struct in_addr ia; - char *weekdays[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; - char *wdays_short[]={"Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat."}; - char *monthnames[]={"January","February","March","April","May","June","July","August","September","October","November","December"}; - char *mnames_short[]={"Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."}; - CONTACTINFO ci; - BOOL wantempty; - SYSTEMTIME st; - - sztemp[0] = '\0'; - if (!isSeen(hcontact,&st)) { - strcat(sztemp,Translate("")); - return sztemp; - } - - ci.cbSize=sizeof(CONTACTINFO); - ci.hContact=hcontact; - ci.szProto=hcontact?(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0):courProtoName; - for (;loop"); - goto LBL_charPtr; - } - charPtr = Translate(weekdays[isetting]); -LBL_charPtr: - sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",charPtr); - break; - - case 'w': - isetting=st.wDayOfWeek; - if(isetting==-1)goto LBL_noData; - charPtr = Translate(wdays_short[isetting]); - goto LBL_charPtr; - - case 'E': - if (!(isetting=st.wMonth))goto LBL_noData; - charPtr = Translate(monthnames[isetting-1]); - goto LBL_charPtr; - - case 'e': - if (!(isetting=st.wMonth))goto LBL_noData; - charPtr = Translate(mnames_short[isetting-1]); - goto LBL_charPtr; - - case 'H': - if ((isetting=st.wHour)==-1)goto LBL_noData; - goto LBL_2DigNum; - - case 'h': - if ((isetting=st.wHour)==-1)goto LBL_noData; - if (!isetting) isetting=12; - isetting = isetting-((isetting>12)?12:0); - goto LBL_2DigNum; - - case 'p': - if ((isetting=st.wHour)==-1)goto LBL_noData; - charPtr = (isetting>=12)?"PM":"AM"; - goto LBL_charPtr; - - case 'M': - if ((isetting=st.wMinute)==-1)goto LBL_noData; - goto LBL_2DigNum; - - case 'S': - if ((isetting=st.wHour)==-1)goto LBL_noData; - goto LBL_2DigNum; - - case 'n': - charPtr = hcontact?(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hcontact,0):(wantempty?"":"---"); - goto LBL_charPtr; - case 'N': - ci.dwFlag=CNF_NICK; - if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) { - charPtr = ci.pszVal; - } else goto LBL_noData; - goto LBL_charPtr; - case 'G': - { - DBVARIANT dbv; - if (!DBGetContactSetting(hcontact,"CList","Group",&dbv)) { - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - charPtr = szdbsetting; - goto LBL_charPtr; - } else; //do nothing - } - break; - - case 'u': - ci.dwFlag=CNF_UNIQUEID; - if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) - { - switch(ci.type) - { - case CNFT_BYTE: - ltoa(ci.bVal,szdbsetting,10); - break; - case CNFT_WORD: - ltoa(ci.wVal,szdbsetting,10); - break; - case CNFT_DWORD: - ltoa(ci.dVal,szdbsetting,10); - break; - case CNFT_ASCIIZ: - strcpy(szdbsetting,ci.pszVal); - break; - } - - } - else if (ci.szProto != NULL) - { - if (isYahoo(ci.szProto)) // YAHOO support - { - DBVARIANT dbv; - DBGetContactSetting(hcontact,ci.szProto,"id",&dbv); - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - } - else if (isJabber(ci.szProto)) // JABBER support - { - DBVARIANT dbv; - if (DBGetContactSetting(hcontact,ci.szProto,"LoginName",&dbv)) goto LBL_noData; - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - DBGetContactSetting(hcontact,ci.szProto,"LoginServer",&dbv); - strcat(szdbsetting,"@"); - strcat(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - } else goto LBL_noData; - } - else goto LBL_noData; - charPtr = szdbsetting; - goto LBL_charPtr; - - case 's': - if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"StatusTriger":courProtoName,0)) { - strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)(isetting|0x8000),0))); - if (!(isetting&0x8000)) { - strcat(szdbsetting,"/"); - strcat(szdbsetting,Translate("Idle")); - } - charPtr = szdbsetting; - } else goto LBL_noData; - goto LBL_charPtr; - case 'T': - { - DBVARIANT dbv; - if (!DBGetContactSetting(hcontact,"CList","StatusMsg",&dbv)) { - sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",dbv.pszVal); - DBFreeVariant(&dbv); - } else goto LBL_noData; - } - break; - case 'o': - if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"OldStatus":courProtoName,0)) { - strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)isetting,0))); - if (includeIdle) if (hcontact) if (DBGetContactSettingByte(hcontact,S_MOD,"OldIdle",0)) { - strcat(szdbsetting,"/"); - strcat(szdbsetting,Translate("Idle")); - } - charPtr = szdbsetting; - } else goto LBL_noData; - goto LBL_charPtr; - - case 'i': - case 'r': if (isJabber(ci.szProto)) { - DBVARIANT dbv; - if (!DBGetContactSetting(hcontact,ci.szProto,szstring[loop]=='i'?"Resource":"System",&dbv)) { - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - charPtr = szdbsetting; - } else goto LBL_noData; - } else { - dwsetting=DBGetContactSettingDword(hcontact,ci.szProto,szstring[loop]=='i'?"IP":"RealIP",0); - if(dwsetting){ - ia.S_un.S_addr=htonl(dwsetting); - charPtr = inet_ntoa(ia); - } else goto LBL_noData; - } - goto LBL_charPtr; - case 'P':if (ci.szProto) charPtr = ci.szProto; else charPtr = wantempty?"":"ProtoUnknown"; - goto LBL_charPtr; - case 'b': - charPtr = /*"\n"*/"\x0D\x0A"; - goto LBL_charPtr; - case 'C': // Get Client Info - if (isMSN(ci.szProto)) { - if (hcontact) { - dwsetting = (int)DBGetContactSettingDword(hcontact,ci.szProto,"FlagBits",0); - wsprintf(szdbsetting,"MSNC%i",(dwsetting&0x70000000)>>28); - if (dwsetting & 0x00000001) strcat(szdbsetting," MobD"); //Mobile Device - if (dwsetting & 0x00000004) strcat(szdbsetting," InkG"); //GIF Ink Send/Receive - if (dwsetting & 0x00000008) strcat(szdbsetting," InkI"); //ISF Ink Send/Receive - if (dwsetting & 0x00000010) strcat(szdbsetting," WCam"); //Webcam - if (dwsetting & 0x00000020) strcat(szdbsetting," MPkt"); //Multi packet messages - if (dwsetting & 0x00000040) strcat(szdbsetting," SMSr"); //Paging - if (dwsetting & 0x00000080) strcat(szdbsetting," DSMS"); //Using MSN Direct - if (dwsetting & 0x00000200) strcat(szdbsetting," WebM"); //WebMessenger - if (dwsetting & 0x00001000) strcat(szdbsetting," MS7+"); //Unknown (Msgr 7 always[?] sets it) - if (dwsetting & 0x00004000) strcat(szdbsetting," DirM"); //DirectIM - if (dwsetting & 0x00008000) strcat(szdbsetting," Wink"); //Send/Receive Winks - if (dwsetting & 0x00010000) strcat(szdbsetting," MSrc"); //MSN Search ?? - if (dwsetting & 0x00040000) strcat(szdbsetting," VoiC"); //Voice Clips - } else strcpy(szdbsetting,"Miranda"); - } else { - DBVARIANT dbv; - if (!DBGetContactSetting(hcontact,ci.szProto,"MirVer",&dbv)) { - strcpy(szdbsetting,dbv.pszVal); - DBFreeVariant(&dbv); - } else goto LBL_noData; - } - charPtr = szdbsetting; - goto LBL_charPtr; - case 't': - charPtr = "\t"; - goto LBL_charPtr; - - default: - strncpy(szdbsetting,szstring+loop-1,2); - goto LBL_charPtr; - } - } - } - - return sztemp; -} - - - -void _DBWriteTime(SYSTEMTIME *st,HANDLE hcontact) -{ - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Day",st->wDay); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Month",st->wMonth); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Year",st->wYear); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Hours",st->wHour); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Minutes",st->wMinute); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Seconds",st->wSecond); - DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"WeekDay",st->wDayOfWeek); - -} - -void DBWriteTimeTS(DWORD t, HANDLE hcontact){ - SYSTEMTIME st; - FILETIME ft; - ULONGLONG ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,t,0), 10000000) + NUM100NANOSEC; - ft.dwLowDateTime = (DWORD)ll; - ft.dwHighDateTime = (DWORD)(ll >> 32); - FileTimeToSystemTime(&ft, &st); - DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",t); - _DBWriteTime(&st, hcontact); -} -void GetColorsFromDWord(LPCOLORREF First, LPCOLORREF Second, DWORD colDword){ - WORD temp; - COLORREF res=0; - temp = (WORD)(colDword>>16); - res |= ((temp & 0x1F) <<3); - res |= ((temp & 0x3E0) <<6); - res |= ((temp & 0x7C00) <<9); - if (First) *First = res; - res = 0; - temp = (WORD)colDword; - res |= ((temp & 0x1F) <<3); - res |= ((temp & 0x3E0) <<6); - res |= ((temp & 0x7C00) <<9); - if (Second) *Second = res; -} - -DWORD StatusColors15bits[] = { - 0x63180000, // 0x00C0C0C0, 0x00000000, Offline - LightGray - 0x7B350000, // 0x00F0C8A8, 0x00000000, Online - LightBlue - 0x33fe0000, // 0x0070E0E0, 0x00000000, Away -LightOrange - 0x295C0000, // 0x005050E0, 0x00000000, DND -DarkRed - 0x5EFD0000, // 0x00B8B8E8, 0x00000000, NA -LightRed - 0x295C0000, // 0x005050E0, 0x00000000, Occupied - 0x43900000, // 0x0080E080, 0x00000000, Free for chat - LightGreen - 0x76AF0000, // 0x00E8A878, 0x00000000, Invisible - 0x431C0000, // 0x0080C0E0, 0x00000000, On the phone - 0x5EFD0000, // 0x00B8B8E8, 0x00000000, Out to lunch -}; - -DWORD GetDWordFromColors(COLORREF First, COLORREF Second){ - DWORD res = 0; - res |= (First&0xF8)>>3; - res |= (First&0xF800)>>6; - res |= (First&0xF80000)>>9; - res <<= 16; - res |= (Second&0xF8)>>3; - res |= (Second&0xF800)>>6; - res |= (Second&0xF80000)>>9; - return res; -} - -LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - - switch(message) { - case WM_COMMAND: - if (HIWORD(wParam) == STN_CLICKED){ - HANDLE hContact = PUGetContact(hwnd); - if (hContact > 0) CallService(MS_MSG_SENDMESSAGE,(WPARAM)hContact,0); - } - case WM_CONTEXTMENU: - PUDeletePopUp(hwnd); - break; - case UM_INITPOPUP: return 0; - } - return DefWindowProc(hwnd, message, wParam, lParam); -}; - -void ShowPopup(HANDLE hcontact, const char * lpzProto, int newStatus){ - if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return; - if (ServiceExists(MS_POPUP_QUERY)) { - if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)) { - if (!DBGetContactSettingByte(hcontact,"CList","Hidden",0)) { - POPUPDATAEX ppd = {0}; - DBVARIANT dbv = {0}; - char szstamp[10]; - DWORD sett; - sprintf(szstamp, "Col_%d",newStatus-ID_STATUS_OFFLINE); - sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[newStatus-ID_STATUS_OFFLINE]); - GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,sett); - ppd.lchContact = hcontact; - ppd.lchIcon = LoadSkinnedProtoIcon(lpzProto, newStatus); - strncpy(ppd.lpzContactName,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP,hcontact,0),MAX_CONTACTNAME); - DBFreeVariant(&dbv); - strncpy(ppd.lpzText,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT,hcontact,0),MAX_SECONDLINE); - DBFreeVariant(&dbv); - ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); - } - } - } -} - -void myPlaySound(HANDLE hcontact, WORD newStatus, WORD oldStatus){ - if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return; - //oldStatus and hcontact are not used yet - if (DBGetContactSettingByte(NULL,"Skin","UseSound",1)) { - char * soundname=0; - if ((newStatus==ID_STATUS_ONLINE) || (newStatus==ID_STATUS_FREECHAT)) soundname = "LastSeenTrackedStatusOnline"; - else if (newStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusOffline"; - else if (oldStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusFromOffline"; - else soundname = "LastSeenTrackedStatusChange"; - if (!DBGetContactSettingByte(NULL,"SkinSoundsOff",soundname,0)) { - DBVARIANT dbv; - if (!DBGetContactSetting(NULL,"SkinSounds",soundname,&dbv)) { - PlaySoundA(dbv.pszVal, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT); - DBFreeVariant(&dbv); -} } } } - -//will give hContact position or zero -int isContactQueueActive(HANDLE hContact){ - int i = 0; - if (!hContact) { -// MessageBox(0,"Is myself in the queue: never","LastSeen-Mod",0); - return 0; - } - for (i=1;ihContact==hContact) return i; - } - return 0; -} - -//will add hContact to queue and will return position; -int addContactToQueue(HANDLE hContact){ - int i = 0; - if (!hContact) { -// MessageBox(0,"Adding myself to queue","LastSeen-Mod",0); - return 0; - } - for (i=1;iqueueIndex = i; - contactQueue[i]->hContact = hContact; - return i; - } - } - //no free space. Create some - //MessageBox(0,"Creating more space","LastSeen-Mod",0); - 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]->queueIndex = i; - contactQueue[i]->hContact = hContact; - contactQueueSize += 16; - return i; -} - -static DWORD __stdcall waitThread(logthread_info* infoParam) -{ -// char str[MAXMODULELABELLENGTH]; -// sprintf(str,"In Thread: %s; %s; %s\n", -// infoParam->sProtoName, -// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0), -// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) -// ); -// OutputDebugStringA(str); - WORD prevStatus = DBGetContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); - Sleep(1500); // I hope in 1.5 second all the needed info will be set - if (includeIdle){ - if (DBGetContactSettingDword(infoParam->hContact,infoParam->sProtoName,"IdleTS",0)) { - infoParam->courStatus &=0x7FFF; - } - } - if (infoParam->courStatus != prevStatus){ - DBWriteContactSettingWord(infoParam->hContact,S_MOD,"OldStatus",(WORD)(prevStatus|0x8000)); - if (includeIdle){ - DBWriteContactSettingByte(infoParam->hContact,S_MOD,"OldIdle",(BYTE)((prevStatus&0x8000)==0)); - } - DBWriteContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",infoParam->courStatus); - } -// sprintf(str,"OutThread: %s; %s; %s\n", -// infoParam->sProtoName, -// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0), -// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) -// ); -// infoParam->hContact = 0; //declare the slot as empty - contactQueue[infoParam->queueIndex] = 0; - free(infoParam); -// OutputDebugStringA(str); - return 0; -} - - - -int UpdateValues(HANDLE hContact,LPARAM lparam) -{ - FORK_THREADEX_PARAMS params; - DWORD dwThreadId; - DBCONTACTWRITESETTING *cws; - BOOL isIdleEvent; - // to make this code faster - if (!hContact) 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); - if (includeIdle){ - if (DBGetContactSettingByte(hContact,S_MOD,"OldIdle",0)) prevStatus &= 0x7FFF; - else prevStatus |= 0x8000; - } - if ((cws->value.wVal|0x8000)<=ID_STATUS_OFFLINE) - { - char * proto; - // 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); - { - DWORD t; - char *str = 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); - } - - if (!DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)) - { - char * sProto; - if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) - FileWrite(hContact); - - if (CallProtoService(sProto = - (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,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); - } } - - if(DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0)) - HistoryWrite(hContact); - - if(DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) - ShowHistory(hContact, 1); - } - - } else { - - if(cws->value.wVal==prevStatus && !DBGetContactSettingByte(hContact,S_MOD,"Offline",0)) - return 0; - - DBWriteTimeTS(time(NULL),hContact); - - //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,"KeepHistory",0)) HistoryWrite(hContact); - if(DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) ShowHistory(hContact, 1); - DBWriteContactSettingByte(hContact,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); - strncpy(contactQueue[index]->sProtoName,cws->szModule,MAXMODULELABELLENGTH); - //forkthreadex(NULL, 0, waitThread, contactQueue[index], 0, 0); - params.pFunc = waitThread; - params.arg = contactQueue[index]; - params.iStackSize = 0; - params.threadID = &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; - } } - - return 0; -} - -static DWORD __stdcall cleanThread(logthread_info* infoParam) -{ - HANDLE hcontact=NULL; -// char str[MAXMODULELABELLENGTH]; -// sprintf(str,"In Clean: %s; %s; %s\n", -// infoParam->sProtoName, -// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0), -// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) -// ); -// OutputDebugStringA(str); - Sleep(10000); // I hope in 10 secons all logged-in contacts will be listed - //Searching for contact marked as online but now are offline - - hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); - while(hcontact!=NULL) - { - char * contactProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); - if (contactProto) { - if (!strncmp(infoParam->sProtoName,contactProto,MAXMODULELABELLENGTH)) { - WORD oldStatus; - if ( (oldStatus = (DBGetContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE))|0x8000)>ID_STATUS_OFFLINE){ - if (DBGetContactSettingWord(hcontact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){ - DBWriteContactSettingWord(hcontact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000)); - if (includeIdle)DBWriteContactSettingByte(hcontact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1)); - DBWriteContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); - } - } - } - } - hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hcontact,0); - } - -// sprintf(str,"OutClean: %s; %s; %s\n", -// infoParam->sProtoName, -// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0), -// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) -// ); - { - char *str = malloc(MAXMODULELABELLENGTH+9); - mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",infoParam->sProtoName); - DBDeleteContactSetting(NULL,S_MOD,str); - free(str); - } - free(infoParam); -// OutputDebugStringA(str); - return 0; -} - - -int ModeChange(WPARAM wparam,LPARAM lparam) -{ - ACKDATA *ack; - WORD isetting=0; - FORK_THREADEX_PARAMS params; - DWORD dwThreadId; - - ack=(ACKDATA *)lparam; - - if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0; - courProtoName = (char *)ack->szModule; - if (!IsWatchedProtocol(courProtoName) && strncmp(courProtoName,"MetaContacts",12)) - { - //MessageBox(NULL,"Protocol not watched",courProtoName,0); - return 0; - } - - DBWriteTimeTS(time(NULL),NULL); - -// isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); - isetting=(WORD)ack->lParam; - if (isettingID_STATUS_OFFLINE)&&((WORD)ack->hProcess<=ID_STATUS_OFFLINE)) { - //we have just loged-in - db_dword_set(NULL, "UserOnline", ack->szModule, GetTickCount()); - if (IsWatchedProtocol(ack->szModule)) { - logthread_info *info; - info = (logthread_info *)malloc(sizeof(logthread_info)); - strncpy(info->sProtoName,courProtoName,MAXMODULELABELLENGTH); - info->hContact = 0; - info->courStatus = 0; - //forkthreadex(NULL, 0, cleanThread, info, 0, 0); - params.pFunc = cleanThread; - params.arg = info; - params.iStackSize = 0; - params.threadID = &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); - time_t t; - time(&t); - mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",ack->szModule); - DBWriteContactSettingDword(NULL,S_MOD,str,t); - free(str); - } } - if (isetting==DBGetContactSettingWord(NULL,S_MOD,courProtoName,ID_STATUS_OFFLINE)) return 0; - DBWriteContactSettingWord(NULL,S_MOD,courProtoName,isetting); - - // log "myself" - if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) - FileWrite(NULL); - -// if(isetting==ID_STATUS_OFFLINE) //this is removed 'cause I want other contacts to be logged only if the status changed while I was offline -// SetOffline(); - - courProtoName = NULL; - - return 0; -} - -short int isDbZero(HANDLE hContact, const char *module_name, const char *setting_name){ - DBVARIANT dbv; - if (!DBGetContactSetting(hContact, module_name, setting_name, &dbv)) { - short int res = 0; - switch (dbv.type) { - case DBVT_BYTE: res=dbv.bVal==0; break; - case DBVT_WORD: res=dbv.wVal==0; break; - case DBVT_DWORD: res=dbv.dVal==0; break; - case DBVT_BLOB: res=dbv.cpbVal==0; break; - default: res=dbv.pszVal[0]==0; break; - } - DBFreeVariant(&dbv); - return res; - } else return -1; -} - -WCHAR *any_to_IdleNotidleUnknown(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) { - short int r = isDbZero(hContact, module_name, setting_name); - if (r==-1){ - wcsncpy(buff, TranslateW(L"Unknown"), bufflen); - } else { - wcsncpy(buff, TranslateW(r?L"Not Idle":L"Idle"), bufflen); - }; - buff[bufflen - 1] = 0; - return buff; -} -WCHAR *any_to_Idle(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) { - if(isDbZero(hContact, module_name, setting_name)==0) { //DB setting is NOT zero and exists - buff[0] = L'/'; - wcsncpy((WCHAR *)&buff[1], TranslateW(L"Idle"), bufflen-1); - } else buff[0] = 0; - buff[bufflen - 1] = 0; - return buff; -} - - -/*int GetInfoAck(WPARAM wparam,LPARAM lparam) -{ - ACKDATA *ack; - DWORD dwsetting=0; - - ack=(ACKDATA *)lparam; - - if(ack->type!=ACKTYPE_GETINFO || ack->hContact==NULL) return 0; - if (((int)ack->hProcess-1)!=(int)ack->lParam) return 0; - - dwsetting=DBGetContactSettingDword(ack->hContact,ack->szModule,"IP",0); - if(dwsetting) - DBWriteContactSettingDword(ack->hContact,S_MOD,"IP",dwsetting); - - dwsetting=DBGetContactSettingDword(ack->hContact,ack->szModule,"RealIP",0); - if(dwsetting) - DBWriteContactSettingDword(ack->hContact,S_MOD,"RealIP",dwsetting); - - return 0; -}*/ - - - -/*void SetOffline(void) -{ - HANDLE hcontact=NULL; - char * szProto; - - hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); - while(hcontact!=NULL) - { - szProto=(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); - if (szProto != NULL && IsWatchedProtocol(szProto)) { - DBWriteContactSettingByte(hcontact,S_MOD,"Offline",1); - } - hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hcontact,0); - } -}*/ - - - diff --git a/plugins/SeenPlugin/utils.cpp b/plugins/SeenPlugin/utils.cpp new file mode 100644 index 0000000000..4d0e64d00c --- /dev/null +++ b/plugins/SeenPlugin/utils.cpp @@ -0,0 +1,924 @@ +/* +"Last Seen mod" plugin for Miranda IM +Copyright ( C ) 2002-03 micron-x +Copyright ( C ) 2005-07 Y.B. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or ( at your option ) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +File name : $URL: http://svn.berlios.de/svnroot/repos/mgoodies/trunk/lastseen-mod/utils.c $ +Revision : $Rev: 1570 $ +Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $ +Last change by : $Author: y_b $ +*/ +#include "seen.h" +#include +#include + + +void FileWrite(HANDLE); +void HistoryWrite(HANDLE hcontact); +//void SetOffline(void); +void ShowHistory(HANDLE hContact, BYTE isAlert); + +char * courProtoName = 0; + +//copied from ..\..\miranda32\protocols\protocols\protocols.c +PROTOCOLDESCRIPTOR* Proto_IsProtocolLoaded(const char* szProto) +{ + return (PROTOCOLDESCRIPTOR*) CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)szProto); +} + + +/* +Returns true if the protocols is to be monitored +*/ +int IsWatchedProtocol(const char* szProto) +{ + DBVARIANT dbv; + char *szProtoPointer, *szWatched; + int iProtoLen, iWatchedLen; + int retval = 0; + PROTOCOLDESCRIPTOR *pd; + + if (szProto == NULL) + return 0; + + pd=Proto_IsProtocolLoaded(szProto); + if (pd==NULL || pd->type!=PROTOTYPE_PROTOCOL || CallProtoService(pd->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) + return 0; + + iProtoLen = (int)_tcslen(szProto); + if(DBGetContactSetting(NULL, S_MOD, "WatchedProtocols", &dbv)) + szWatched = DEFAULT_WATCHEDPROTOCOLS; + else + szWatched = dbv.pszVal; + iWatchedLen = (int)_tcslen(szWatched); + + if (*szWatched == '\0') + { + retval=1; //empty string: all protocols are watched + } + else + { + char sTemp [MAXMODULELABELLENGTH+1]=""; + strcat(sTemp,szProto); + strcat(sTemp," "); + szProtoPointer = strstr(szWatched, sTemp); + if (szProtoPointer == NULL) + retval=0; + else + retval=1; + } + + DBFreeVariant(&dbv); + return retval; +} + +BOOL isYahoo(char * protoname){ + if (protoname) { + char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (pszUniqueSetting){ + return (!strcmp(pszUniqueSetting,"yahoo_id")); + } } + return FALSE; +} +BOOL isJabber(char * protoname){ + if (protoname) { + char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (pszUniqueSetting){ + return (!strcmp(pszUniqueSetting,"jid")); + } } + return FALSE; +} +BOOL isICQ(char * protoname){ + if (protoname) { + char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (pszUniqueSetting){ + return (!strcmp(pszUniqueSetting,"UIN")); + } } + return FALSE; +} +BOOL isMSN(char * protoname){ + if (protoname) { + char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (pszUniqueSetting){ + return (!strcmp(pszUniqueSetting,"e-mail")); + } } + return FALSE; +} + +DWORD isSeen(HANDLE hcontact, SYSTEMTIME *st){ + DWORD res = 0; + FILETIME ft; + ULONGLONG ll; + res = DBGetContactSettingDword(hcontact,S_MOD,"seenTS",0); + if (res){ + if (st) { + ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,res,0), 10000000) + NUM100NANOSEC; + ft.dwLowDateTime = (DWORD)ll; + ft.dwHighDateTime = (DWORD)(ll >> 32); + FileTimeToSystemTime(&ft, st); + } + return res; + } else { + SYSTEMTIME lst; + ZeroMemory(&lst,sizeof(lst)); + if (lst.wYear = DBGetContactSettingWord(hcontact,S_MOD,"Year",0)) { + if (lst.wMonth = DBGetContactSettingWord(hcontact,S_MOD,"Month",0)) { + if (lst.wDay = DBGetContactSettingWord(hcontact,S_MOD,"Day",0)) { + lst.wDayOfWeek = DBGetContactSettingWord(hcontact,S_MOD,"WeekDay",0); + lst.wHour = DBGetContactSettingWord(hcontact,S_MOD,"Hours",0); + lst.wMinute = DBGetContactSettingWord(hcontact,S_MOD,"Minutes",0); + lst.wSecond = DBGetContactSettingWord(hcontact,S_MOD,"Seconds",0); + if (SystemTimeToFileTime(&lst,&ft)) { + ll = ((LONGLONG)ft.dwHighDateTime<<32)|((LONGLONG)ft.dwLowDateTime); + ll -= NUM100NANOSEC; + ll /= 10000000; + //perform LOCALTOTIMESTAMP + res = (DWORD)ll - CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,0,0); + //nevel look for Year/Month/Day/Hour/Minute/Second again + DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",res); + } + } } } + if (st) CopyMemory (st, &lst, sizeof (SYSTEMTIME)); + } + return res; +} + +char *ParseString(char *szstring,HANDLE hcontact,BYTE isfile) +{ +#define MAXSIZE 1024 + static char sztemp[MAXSIZE+1]; + int sztemplen = 0; + char szdbsetting[128]=""; + char *charPtr; + UINT loop=0; + int isetting=0; + DWORD dwsetting=0; + struct in_addr ia; + char *weekdays[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; + char *wdays_short[]={"Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat."}; + char *monthnames[]={"January","February","March","April","May","June","July","August","September","October","November","December"}; + char *mnames_short[]={"Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."}; + CONTACTINFO ci; + BOOL wantempty; + SYSTEMTIME st; + + sztemp[0] = '\0'; + if (!isSeen(hcontact,&st)) { + strcat(sztemp,Translate("")); + return sztemp; + } + + ci.cbSize=sizeof(CONTACTINFO); + ci.hContact=hcontact; + ci.szProto=hcontact?(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0):courProtoName; + for (;loop"); + goto LBL_charPtr; + } + charPtr = Translate(weekdays[isetting]); +LBL_charPtr: + sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",charPtr); + break; + + case 'w': + isetting=st.wDayOfWeek; + if(isetting==-1)goto LBL_noData; + charPtr = Translate(wdays_short[isetting]); + goto LBL_charPtr; + + case 'E': + if (!(isetting=st.wMonth))goto LBL_noData; + charPtr = Translate(monthnames[isetting-1]); + goto LBL_charPtr; + + case 'e': + if (!(isetting=st.wMonth))goto LBL_noData; + charPtr = Translate(mnames_short[isetting-1]); + goto LBL_charPtr; + + case 'H': + if ((isetting=st.wHour)==-1)goto LBL_noData; + goto LBL_2DigNum; + + case 'h': + if ((isetting=st.wHour)==-1)goto LBL_noData; + if (!isetting) isetting=12; + isetting = isetting-((isetting>12)?12:0); + goto LBL_2DigNum; + + case 'p': + if ((isetting=st.wHour)==-1)goto LBL_noData; + charPtr = (isetting>=12)?"PM":"AM"; + goto LBL_charPtr; + + case 'M': + if ((isetting=st.wMinute)==-1)goto LBL_noData; + goto LBL_2DigNum; + + case 'S': + if ((isetting=st.wHour)==-1)goto LBL_noData; + goto LBL_2DigNum; + + case 'n': + charPtr = hcontact?(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hcontact,0):(wantempty?"":"---"); + goto LBL_charPtr; + case 'N': + ci.dwFlag=CNF_NICK; + if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) { + charPtr = ci.pszVal; + } else goto LBL_noData; + goto LBL_charPtr; + case 'G': + { + DBVARIANT dbv; + if (!DBGetContactSetting(hcontact,"CList","Group",&dbv)) { + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + charPtr = szdbsetting; + goto LBL_charPtr; + } else; //do nothing + } + break; + + case 'u': + ci.dwFlag=CNF_UNIQUEID; + if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) + { + switch(ci.type) + { + case CNFT_BYTE: + ltoa(ci.bVal,szdbsetting,10); + break; + case CNFT_WORD: + ltoa(ci.wVal,szdbsetting,10); + break; + case CNFT_DWORD: + ltoa(ci.dVal,szdbsetting,10); + break; + case CNFT_ASCIIZ: + strcpy(szdbsetting,ci.pszVal); + break; + } + + } + else if (ci.szProto != NULL) + { + if (isYahoo(ci.szProto)) // YAHOO support + { + DBVARIANT dbv; + DBGetContactSetting(hcontact,ci.szProto,"id",&dbv); + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + } + else if (isJabber(ci.szProto)) // JABBER support + { + DBVARIANT dbv; + if (DBGetContactSetting(hcontact,ci.szProto,"LoginName",&dbv)) goto LBL_noData; + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + DBGetContactSetting(hcontact,ci.szProto,"LoginServer",&dbv); + strcat(szdbsetting,"@"); + strcat(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + } else goto LBL_noData; + } + else goto LBL_noData; + charPtr = szdbsetting; + goto LBL_charPtr; + + case 's': + if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"StatusTriger":courProtoName,0)) { + strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)(isetting|0x8000),0))); + if (!(isetting&0x8000)) { + strcat(szdbsetting,"/"); + strcat(szdbsetting,Translate("Idle")); + } + charPtr = szdbsetting; + } else goto LBL_noData; + goto LBL_charPtr; + case 'T': + { + DBVARIANT dbv; + if (!DBGetContactSetting(hcontact,"CList","StatusMsg",&dbv)) { + sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",dbv.pszVal); + DBFreeVariant(&dbv); + } else goto LBL_noData; + } + break; + case 'o': + if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"OldStatus":courProtoName,0)) { + strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)isetting,0))); + if (includeIdle) if (hcontact) if (DBGetContactSettingByte(hcontact,S_MOD,"OldIdle",0)) { + strcat(szdbsetting,"/"); + strcat(szdbsetting,Translate("Idle")); + } + charPtr = szdbsetting; + } else goto LBL_noData; + goto LBL_charPtr; + + case 'i': + case 'r': if (isJabber(ci.szProto)) { + DBVARIANT dbv; + if (!DBGetContactSetting(hcontact,ci.szProto,szstring[loop]=='i'?"Resource":"System",&dbv)) { + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + charPtr = szdbsetting; + } else goto LBL_noData; + } else { + dwsetting=DBGetContactSettingDword(hcontact,ci.szProto,szstring[loop]=='i'?"IP":"RealIP",0); + if(dwsetting){ + ia.S_un.S_addr=htonl(dwsetting); + charPtr = inet_ntoa(ia); + } else goto LBL_noData; + } + goto LBL_charPtr; + case 'P':if (ci.szProto) charPtr = ci.szProto; else charPtr = wantempty?"":"ProtoUnknown"; + goto LBL_charPtr; + case 'b': + charPtr = /*"\n"*/"\x0D\x0A"; + goto LBL_charPtr; + case 'C': // Get Client Info + if (isMSN(ci.szProto)) { + if (hcontact) { + dwsetting = (int)DBGetContactSettingDword(hcontact,ci.szProto,"FlagBits",0); + wsprintf(szdbsetting,"MSNC%i",(dwsetting&0x70000000)>>28); + if (dwsetting & 0x00000001) strcat(szdbsetting," MobD"); //Mobile Device + if (dwsetting & 0x00000004) strcat(szdbsetting," InkG"); //GIF Ink Send/Receive + if (dwsetting & 0x00000008) strcat(szdbsetting," InkI"); //ISF Ink Send/Receive + if (dwsetting & 0x00000010) strcat(szdbsetting," WCam"); //Webcam + if (dwsetting & 0x00000020) strcat(szdbsetting," MPkt"); //Multi packet messages + if (dwsetting & 0x00000040) strcat(szdbsetting," SMSr"); //Paging + if (dwsetting & 0x00000080) strcat(szdbsetting," DSMS"); //Using MSN Direct + if (dwsetting & 0x00000200) strcat(szdbsetting," WebM"); //WebMessenger + if (dwsetting & 0x00001000) strcat(szdbsetting," MS7+"); //Unknown (Msgr 7 always[?] sets it) + if (dwsetting & 0x00004000) strcat(szdbsetting," DirM"); //DirectIM + if (dwsetting & 0x00008000) strcat(szdbsetting," Wink"); //Send/Receive Winks + if (dwsetting & 0x00010000) strcat(szdbsetting," MSrc"); //MSN Search ?? + if (dwsetting & 0x00040000) strcat(szdbsetting," VoiC"); //Voice Clips + } else strcpy(szdbsetting,"Miranda"); + } else { + DBVARIANT dbv; + if (!DBGetContactSetting(hcontact,ci.szProto,"MirVer",&dbv)) { + strcpy(szdbsetting,dbv.pszVal); + DBFreeVariant(&dbv); + } else goto LBL_noData; + } + charPtr = szdbsetting; + goto LBL_charPtr; + case 't': + charPtr = "\t"; + goto LBL_charPtr; + + default: + strncpy(szdbsetting,szstring+loop-1,2); + goto LBL_charPtr; + } + } + } + + return sztemp; +} + + + +void _DBWriteTime(SYSTEMTIME *st,HANDLE hcontact) +{ + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Day",st->wDay); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Month",st->wMonth); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Year",st->wYear); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Hours",st->wHour); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Minutes",st->wMinute); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Seconds",st->wSecond); + DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"WeekDay",st->wDayOfWeek); + +} + +void DBWriteTimeTS(DWORD t, HANDLE hcontact){ + SYSTEMTIME st; + FILETIME ft; + ULONGLONG ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,t,0), 10000000) + NUM100NANOSEC; + ft.dwLowDateTime = (DWORD)ll; + ft.dwHighDateTime = (DWORD)(ll >> 32); + FileTimeToSystemTime(&ft, &st); + DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",t); + _DBWriteTime(&st, hcontact); +} +void GetColorsFromDWord(LPCOLORREF First, LPCOLORREF Second, DWORD colDword){ + WORD temp; + COLORREF res=0; + temp = (WORD)(colDword>>16); + res |= ((temp & 0x1F) <<3); + res |= ((temp & 0x3E0) <<6); + res |= ((temp & 0x7C00) <<9); + if (First) *First = res; + res = 0; + temp = (WORD)colDword; + res |= ((temp & 0x1F) <<3); + res |= ((temp & 0x3E0) <<6); + res |= ((temp & 0x7C00) <<9); + if (Second) *Second = res; +} + +DWORD StatusColors15bits[] = { + 0x63180000, // 0x00C0C0C0, 0x00000000, Offline - LightGray + 0x7B350000, // 0x00F0C8A8, 0x00000000, Online - LightBlue + 0x33fe0000, // 0x0070E0E0, 0x00000000, Away -LightOrange + 0x295C0000, // 0x005050E0, 0x00000000, DND -DarkRed + 0x5EFD0000, // 0x00B8B8E8, 0x00000000, NA -LightRed + 0x295C0000, // 0x005050E0, 0x00000000, Occupied + 0x43900000, // 0x0080E080, 0x00000000, Free for chat - LightGreen + 0x76AF0000, // 0x00E8A878, 0x00000000, Invisible + 0x431C0000, // 0x0080C0E0, 0x00000000, On the phone + 0x5EFD0000, // 0x00B8B8E8, 0x00000000, Out to lunch +}; + +DWORD GetDWordFromColors(COLORREF First, COLORREF Second){ + DWORD res = 0; + res |= (First&0xF8)>>3; + res |= (First&0xF800)>>6; + res |= (First&0xF80000)>>9; + res <<= 16; + res |= (Second&0xF8)>>3; + res |= (Second&0xF800)>>6; + res |= (Second&0xF80000)>>9; + return res; +} + +LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { + + switch(message) { + case WM_COMMAND: + if (HIWORD(wParam) == STN_CLICKED){ + HANDLE hContact = PUGetContact(hwnd); + if (hContact > 0) CallService(MS_MSG_SENDMESSAGE,(WPARAM)hContact,0); + } + case WM_CONTEXTMENU: + PUDeletePopUp(hwnd); + break; + case UM_INITPOPUP: return 0; + } + return DefWindowProc(hwnd, message, wParam, lParam); +}; + +void ShowPopup(HANDLE hcontact, const char * lpzProto, int newStatus){ + if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return; + if (ServiceExists(MS_POPUP_QUERY)) { + if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)) { + if (!DBGetContactSettingByte(hcontact,"CList","Hidden",0)) { + POPUPDATAEX ppd = {0}; + DBVARIANT dbv = {0}; + char szstamp[10]; + DWORD sett; + sprintf(szstamp, "Col_%d",newStatus-ID_STATUS_OFFLINE); + sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[newStatus-ID_STATUS_OFFLINE]); + GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,sett); + ppd.lchContact = hcontact; + ppd.lchIcon = LoadSkinnedProtoIcon(lpzProto, newStatus); + strncpy(ppd.lpzContactName,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP,hcontact,0),MAX_CONTACTNAME); + DBFreeVariant(&dbv); + strncpy(ppd.lpzText,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT,hcontact,0),MAX_SECONDLINE); + DBFreeVariant(&dbv); + ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); + } + } + } +} + +void myPlaySound(HANDLE hcontact, WORD newStatus, WORD oldStatus){ + if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return; + //oldStatus and hcontact are not used yet + if (DBGetContactSettingByte(NULL,"Skin","UseSound",1)) { + char * soundname=0; + if ((newStatus==ID_STATUS_ONLINE) || (newStatus==ID_STATUS_FREECHAT)) soundname = "LastSeenTrackedStatusOnline"; + else if (newStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusOffline"; + else if (oldStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusFromOffline"; + else soundname = "LastSeenTrackedStatusChange"; + if (!DBGetContactSettingByte(NULL,"SkinSoundsOff",soundname,0)) { + DBVARIANT dbv; + if (!DBGetContactSetting(NULL,"SkinSounds",soundname,&dbv)) { + PlaySoundA(dbv.pszVal, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT); + DBFreeVariant(&dbv); +} } } } + +//will give hContact position or zero +int isContactQueueActive(HANDLE hContact){ + int i = 0; + if (!hContact) { +// MessageBox(0,"Is myself in the queue: never","LastSeen-Mod",0); + return 0; + } + for (i=1;ihContact==hContact) return i; + } + return 0; +} + +//will add hContact to queue and will return position; +int addContactToQueue(HANDLE hContact){ + int i = 0; + if (!hContact) { +// MessageBox(0,"Adding myself to queue","LastSeen-Mod",0); + return 0; + } + for (i=1;iqueueIndex = i; + contactQueue[i]->hContact = hContact; + return i; + } + } + //no free space. Create some + //MessageBox(0,"Creating more space","LastSeen-Mod",0); + 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]->queueIndex = i; + contactQueue[i]->hContact = hContact; + contactQueueSize += 16; + return i; +} + +static DWORD __stdcall waitThread(logthread_info* infoParam) +{ +// char str[MAXMODULELABELLENGTH]; +// sprintf(str,"In Thread: %s; %s; %s\n", +// infoParam->sProtoName, +// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0), +// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) +// ); +// OutputDebugStringA(str); + WORD prevStatus = DBGetContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); + Sleep(1500); // I hope in 1.5 second all the needed info will be set + if (includeIdle){ + if (DBGetContactSettingDword(infoParam->hContact,infoParam->sProtoName,"IdleTS",0)) { + infoParam->courStatus &=0x7FFF; + } + } + if (infoParam->courStatus != prevStatus){ + DBWriteContactSettingWord(infoParam->hContact,S_MOD,"OldStatus",(WORD)(prevStatus|0x8000)); + if (includeIdle){ + DBWriteContactSettingByte(infoParam->hContact,S_MOD,"OldIdle",(BYTE)((prevStatus&0x8000)==0)); + } + DBWriteContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",infoParam->courStatus); + } +// sprintf(str,"OutThread: %s; %s; %s\n", +// infoParam->sProtoName, +// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0), +// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) +// ); +// infoParam->hContact = 0; //declare the slot as empty + contactQueue[infoParam->queueIndex] = 0; + free(infoParam); +// OutputDebugStringA(str); + return 0; +} + + + +int UpdateValues(HANDLE hContact,LPARAM lparam) +{ + FORK_THREADEX_PARAMS params; + DWORD dwThreadId; + DBCONTACTWRITESETTING *cws; + BOOL isIdleEvent; + // to make this code faster + if (!hContact) 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); + if (includeIdle){ + if (DBGetContactSettingByte(hContact,S_MOD,"OldIdle",0)) prevStatus &= 0x7FFF; + else prevStatus |= 0x8000; + } + if ((cws->value.wVal|0x8000)<=ID_STATUS_OFFLINE) + { + char * proto; + // 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); + { + DWORD t; + char *str = 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); + } + + if (!DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1)) + { + char * sProto; + if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) + FileWrite(hContact); + + if (CallProtoService(sProto = + (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,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); + } } + + if(DBGetContactSettingByte(NULL,S_MOD,"KeepHistory",0)) + HistoryWrite(hContact); + + if(DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) + ShowHistory(hContact, 1); + } + + } else { + + if(cws->value.wVal==prevStatus && !DBGetContactSettingByte(hContact,S_MOD,"Offline",0)) + return 0; + + DBWriteTimeTS(time(NULL),hContact); + + //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,"KeepHistory",0)) HistoryWrite(hContact); + if(DBGetContactSettingByte(hContact,S_MOD,"OnlineAlert",0)) ShowHistory(hContact, 1); + DBWriteContactSettingByte(hContact,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); + strncpy(contactQueue[index]->sProtoName,cws->szModule,MAXMODULELABELLENGTH); + //forkthreadex(NULL, 0, waitThread, contactQueue[index], 0, 0); + params.pFunc = waitThread; + params.arg = contactQueue[index]; + params.iStackSize = 0; + params.threadID = &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; + } } + + return 0; +} + +static DWORD __stdcall cleanThread(logthread_info* infoParam) +{ + HANDLE hcontact=NULL; +// char str[MAXMODULELABELLENGTH]; +// sprintf(str,"In Clean: %s; %s; %s\n", +// infoParam->sProtoName, +// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0), +// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) +// ); +// OutputDebugStringA(str); + Sleep(10000); // I hope in 10 secons all logged-in contacts will be listed + //Searching for contact marked as online but now are offline + + hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); + while(hcontact!=NULL) + { + char * contactProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); + if (contactProto) { + if (!strncmp(infoParam->sProtoName,contactProto,MAXMODULELABELLENGTH)) { + WORD oldStatus; + if ( (oldStatus = (DBGetContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE))|0x8000)>ID_STATUS_OFFLINE){ + if (DBGetContactSettingWord(hcontact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){ + DBWriteContactSettingWord(hcontact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000)); + if (includeIdle)DBWriteContactSettingByte(hcontact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1)); + DBWriteContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); + } + } + } + } + hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hcontact,0); + } + +// sprintf(str,"OutClean: %s; %s; %s\n", +// infoParam->sProtoName, +// (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)infoParam->hContact,0), +// (const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)infoParam->courStatus,0) +// ); + { + char *str = malloc(MAXMODULELABELLENGTH+9); + mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",infoParam->sProtoName); + DBDeleteContactSetting(NULL,S_MOD,str); + free(str); + } + free(infoParam); +// OutputDebugStringA(str); + return 0; +} + + +int ModeChange(WPARAM wparam,LPARAM lparam) +{ + ACKDATA *ack; + WORD isetting=0; + FORK_THREADEX_PARAMS params; + DWORD dwThreadId; + + ack=(ACKDATA *)lparam; + + if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0; + courProtoName = (char *)ack->szModule; + if (!IsWatchedProtocol(courProtoName) && strncmp(courProtoName,"MetaContacts",12)) + { + //MessageBox(NULL,"Protocol not watched",courProtoName,0); + return 0; + } + + DBWriteTimeTS(time(NULL),NULL); + +// isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); + isetting=(WORD)ack->lParam; + if (isettingID_STATUS_OFFLINE)&&((WORD)ack->hProcess<=ID_STATUS_OFFLINE)) { + //we have just loged-in + db_dword_set(NULL, "UserOnline", ack->szModule, GetTickCount()); + if (IsWatchedProtocol(ack->szModule)) { + logthread_info *info; + info = (logthread_info *)malloc(sizeof(logthread_info)); + strncpy(info->sProtoName,courProtoName,MAXMODULELABELLENGTH); + info->hContact = 0; + info->courStatus = 0; + //forkthreadex(NULL, 0, cleanThread, info, 0, 0); + params.pFunc = cleanThread; + params.arg = info; + params.iStackSize = 0; + params.threadID = &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); + time_t t; + time(&t); + mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",ack->szModule); + DBWriteContactSettingDword(NULL,S_MOD,str,t); + free(str); + } } + if (isetting==DBGetContactSettingWord(NULL,S_MOD,courProtoName,ID_STATUS_OFFLINE)) return 0; + DBWriteContactSettingWord(NULL,S_MOD,courProtoName,isetting); + + // log "myself" + if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0)) + FileWrite(NULL); + +// if(isetting==ID_STATUS_OFFLINE) //this is removed 'cause I want other contacts to be logged only if the status changed while I was offline +// SetOffline(); + + courProtoName = NULL; + + return 0; +} + +short int isDbZero(HANDLE hContact, const char *module_name, const char *setting_name){ + DBVARIANT dbv; + if (!DBGetContactSetting(hContact, module_name, setting_name, &dbv)) { + short int res = 0; + switch (dbv.type) { + case DBVT_BYTE: res=dbv.bVal==0; break; + case DBVT_WORD: res=dbv.wVal==0; break; + case DBVT_DWORD: res=dbv.dVal==0; break; + case DBVT_BLOB: res=dbv.cpbVal==0; break; + default: res=dbv.pszVal[0]==0; break; + } + DBFreeVariant(&dbv); + return res; + } else return -1; +} + +WCHAR *any_to_IdleNotidleUnknown(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) { + short int r = isDbZero(hContact, module_name, setting_name); + if (r==-1){ + wcsncpy(buff, TranslateW(L"Unknown"), bufflen); + } else { + wcsncpy(buff, TranslateW(r?L"Not Idle":L"Idle"), bufflen); + }; + buff[bufflen - 1] = 0; + return buff; +} +WCHAR *any_to_Idle(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) { + if(isDbZero(hContact, module_name, setting_name)==0) { //DB setting is NOT zero and exists + buff[0] = L'/'; + wcsncpy((WCHAR *)&buff[1], TranslateW(L"Idle"), bufflen-1); + } else buff[0] = 0; + buff[bufflen - 1] = 0; + return buff; +} + + +/*int GetInfoAck(WPARAM wparam,LPARAM lparam) +{ + ACKDATA *ack; + DWORD dwsetting=0; + + ack=(ACKDATA *)lparam; + + if(ack->type!=ACKTYPE_GETINFO || ack->hContact==NULL) return 0; + if (((int)ack->hProcess-1)!=(int)ack->lParam) return 0; + + dwsetting=DBGetContactSettingDword(ack->hContact,ack->szModule,"IP",0); + if(dwsetting) + DBWriteContactSettingDword(ack->hContact,S_MOD,"IP",dwsetting); + + dwsetting=DBGetContactSettingDword(ack->hContact,ack->szModule,"RealIP",0); + if(dwsetting) + DBWriteContactSettingDword(ack->hContact,S_MOD,"RealIP",dwsetting); + + return 0; +}*/ + + + +/*void SetOffline(void) +{ + HANDLE hcontact=NULL; + char * szProto; + + hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); + while(hcontact!=NULL) + { + szProto=(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); + if (szProto != NULL && IsWatchedProtocol(szProto)) { + DBWriteContactSettingByte(hcontact,S_MOD,"Offline",1); + } + hcontact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hcontact,0); + } +}*/ + + + -- cgit v1.2.3