diff options
author | George Hazan <george.hazan@gmail.com> | 2012-08-16 20:06:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-08-16 20:06:42 +0000 |
commit | 2581f4f4f48a26ecb3e39cbd6498a4b8654a17b5 (patch) | |
tree | 20e6e4cee22b4cf66cc3d813615ca822d734a192 /plugins/MenuItemEx | |
parent | e4755a369a3612a44340bba01e3809996cfa0edf (diff) |
speeding up menuex
git-svn-id: http://svn.miranda-ng.org/main/trunk@1486 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MenuItemEx')
-rw-r--r-- | plugins/MenuItemEx/src/main.cpp | 56 | ||||
-rw-r--r-- | plugins/MenuItemEx/src/menuex.h | 1 |
2 files changed, 35 insertions, 22 deletions
diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index c99a7358c2..c961dfe624 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -1149,57 +1149,69 @@ static int ContactWindowOpen(WPARAM wparam,LPARAM lParam) return 0;
}
+//========================================================================================
+
+struct SaveStatus
+{
+ HANDLE hContact;
+ int iStatus;
+};
+
+static LIST<SaveStatus> saveStatuses(100, (LIST<SaveStatus>::FTSortFunc)HandleKeySortT);
+
static int ContactSettingChanged( WPARAM wParam, LPARAM lParam )
-{ // NSN
+{
DBCONTACTWRITESETTING *cws = ( DBCONTACTWRITESETTING* )lParam;
- WORD newStatus = 0, oldStatus = 0;
- DWORD dwStatuses = 0;
- time_t tCurrentTime;
- char *lpzProto;
-
- if ( ( HANDLE )wParam == NULL || lstrcmpA( cws->szSetting, "Status" ))
+ HANDLE hContact = ( HANDLE )wParam;
+ if (hContact == NULL || lstrcmpA( cws->szSetting, "Status" ))
return 0;
- newStatus = cws->value.wVal;
- oldStatus = DBGetContactSettingWord((HANDLE)wParam,"UserOnline","OldStatus2",ID_STATUS_OFFLINE );
+ int oldStatus = ID_STATUS_OFFLINE, newStatus = cws->value.wVal;
+
+ SaveStatus tmp = { hContact, 0 }, *p;
+ if (( p = saveStatuses.find( &tmp )) != NULL)
+ oldStatus = p->iStatus;
if (oldStatus == newStatus)
return 0;
- tCurrentTime = time( NULL );
- lpzProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )wParam, 0);
+ char *lpzProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )wParam, 0);
// ignore chat rooms
- if (DBGetContactSettingByte((HANDLE)wParam, lpzProto, "ChatRoom", 0))
+ if (DBGetContactSettingByte(hContact, lpzProto, "ChatRoom", 0))
return 0;
if (oldStatus == ID_STATUS_OFFLINE)
{
// set online timestamp for this contact, only when not set already
- if (!DBGetContactSettingDword( ( HANDLE )wParam, lpzProto, "LogonTS", FALSE))
- DBWriteContactSettingDword( ( HANDLE )wParam, lpzProto, "LogonTS", ( DWORD )tCurrentTime);
+ DBWriteContactSettingDword(hContact, lpzProto, "LogonTS", ( DWORD )time(NULL));
// TODO: dont reset logoff timestamp?
- DBDeleteContactSetting( ( HANDLE )wParam, lpzProto, "LogoffTS");
+ DBDeleteContactSetting(hContact, lpzProto, "LogoffTS");
// TESTING: updating user's details
if (DBGetContactSettingDword(NULL, VISPLG, "flags", vf_default) & VF_REFRESH)
{
// don't refresh Hidden or NotOnList contact's details
- if (!DBGetContactSettingByte((HANDLE)wParam, "CList", "Hidden", 0) && !DBGetContactSettingByte((HANDLE)wParam, "CList", "NotOnList", 0))
- CallContactService( ( HANDLE )wParam, PSS_GETINFO, 0, 0 );
+ if (!DBGetContactSettingByte(hContact, "CList", "Hidden", 0) && !DBGetContactSettingByte((HANDLE)wParam, "CList", "NotOnList", 0))
+ CallContactService(hContact, PSS_GETINFO, 0, 0 );
}
}
if (newStatus == ID_STATUS_OFFLINE)
{
// set offline timestamp for this contact
- DBWriteContactSettingDword( ( HANDLE )wParam, lpzProto, "LogoffTS", ( DWORD )tCurrentTime);
+ DBWriteContactSettingDword(hContact, lpzProto, "LogoffTS", ( DWORD )time(NULL));
// reset logon timestamp
- DBDeleteContactSetting( ( HANDLE )wParam, lpzProto, "LogonTS");
+ DBDeleteContactSetting(hContact, lpzProto, "LogonTS");
+ }
- // set last status for this contact
- DBWriteContactSettingDword( ( HANDLE )wParam, lpzProto, "LastStatus", ( DWORD )oldStatus);
+ if (p != NULL)
+ p->iStatus = newStatus;
+ else {
+ p = new SaveStatus;
+ p->hContact = hContact;
+ p->iStatus = newStatus;
+ saveStatuses.insert(p);
}
- DBWriteContactSettingWord( ( HANDLE )wParam, "UserOnline", "OldStatus2", newStatus);
return 0;
}
diff --git a/plugins/MenuItemEx/src/menuex.h b/plugins/MenuItemEx/src/menuex.h index 5f6540827a..25729660c4 100644 --- a/plugins/MenuItemEx/src/menuex.h +++ b/plugins/MenuItemEx/src/menuex.h @@ -12,6 +12,7 @@ #include "win2k.h"
#include "time.h"
#include "m_system.h"
+#include "m_system_cpp.h"
#include "m_utils.h"
#include "m_options.h"
#include "m_database.h"
|