summaryrefslogtreecommitdiff
path: root/metacontacts
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-20 04:08:52 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-20 04:08:52 +0000
commit2184116cbf00ea959282cc6172934c81c74cb252 (patch)
treebac25447748b339243f6830b838acfcdfa068e0c /metacontacts
parentff978db3ec26fbebe32465f4d1d30cf6aa066768 (diff)
made subcontact priorities configurable
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@289 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'metacontacts')
-rw-r--r--metacontacts/MetaContacts.rc64
-rw-r--r--metacontacts/meta_options.c321
-rw-r--r--metacontacts/meta_services.c22
-rw-r--r--metacontacts/meta_utils.c34
-rw-r--r--metacontacts/metacontacts.h6
-rw-r--r--metacontacts/resource.h15
-rw-r--r--metacontacts/version.h4
7 files changed, 414 insertions, 52 deletions
diff --git a/metacontacts/MetaContacts.rc b/metacontacts/MetaContacts.rc
index dfc971a..35080c8 100644
--- a/metacontacts/MetaContacts.rc
+++ b/metacontacts/MetaContacts.rc
@@ -7,7 +7,7 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
-#include <windows.h>
+#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@@ -195,6 +195,22 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 83
END
+
+ IDD_PRIORITIES, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 259
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 150
+ END
+
+ IDD_HISTORY, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 280
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 102
+ END
END
#endif // APSTUDIO_INVOKED
@@ -204,7 +220,7 @@ END
// Dialog
//
-IDD_OPTIONS DIALOGEX 0, 0, 298, 245
+IDD_OPTIONS DIALOGEX 0, 0, 298, 178
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
@@ -212,7 +228,7 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,9,290,10
CONTROL "Always send to default contact if not offline",IDC_CHK_ALWAYSUSEDEFAULT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,31,290,10
- GROUPBOX "Options",IDC_STATIC,0,0,297,242
+ GROUPBOX "Options",IDC_STATIC,0,0,297,178
CONTROL "Suppress status notification for subcontacts",IDC_CHK_SUPPRESSSTATUS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,42,290,10
GROUPBOX "Context Menu",IDC_STATIC,4,79,289,58
@@ -228,17 +244,8 @@ BEGIN
CONTROL "Display subcontact display name",IDC_RAD_NAME,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,160,144,10
CONTROL "Hide in status bar and status menu (*requires restart, uncheck to set proto icons)",IDC_CHK_SUPPRESSPROTO,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,53,290,10
- GROUPBOX "History (** beware - change at your own risk **)",IDC_STATIC,4,173,289,64,WS_GROUP
- CONTROL "Copy subcontact history to MetaContact when creating or adding",IDC_CHK_COPYHISTORY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,188,282,10
- RTEXT "Number of days to copy (0=all):",IDC_STATIC,9,201,141,8
- EDITTEXT IDC_ED_DAYS,173,200,31,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
CONTROL "Use subcontact message windows",IDC_CHK_SUBWINDOW,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,64,165,10
- CONTROL "Keep MetaContact history synchronized with subcontacts",IDC_CHK_METAHISTORY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,212,282,10
- CONTROL "Keep subcontact history synchronized with MetaContact",IDC_CHK_SUBHISTORY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,224,282,10
CONTROL "Copy subcontact data",IDC_CHK_COPYDATA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,173,64,118,10
CONTROL "Lock name to first contact",IDC_CHK_LOCKHANDLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,173,155,115,10
CONTROL "but only for the current conversation",IDC_CHK_TEMPDEFAULT,
@@ -263,6 +270,38 @@ BEGIN
CTEXT "Please wait while the contact's history is removed.",IDC_STATIC,9,27,167,8
END
+IDD_PRIORITIES DIALOGEX 0, 0, 266, 157
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ GROUPBOX "Subcontact Priorities",IDC_STATIC,7,7,252,143
+ EDITTEXT IDC_ED_PRIORITY,157,78,40,14,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_SP_PRIORITY,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,195,78,11,14
+ RTEXT "Rank:",IDC_STATIC,42,81,49,8
+ RTEXT "Status:",IDC_STATIC,30,57,61,8
+ COMBOBOX IDC_CMB_STATUS,98,53,112,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ RTEXT "Protocol:",IDC_STATIC,30,31,61,8
+ COMBOBOX IDC_CMB_PROTOCOL,98,28,112,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Reset All",IDC_BTN_RESET,87,119,91,14
+ CONTROL "Default",IDC_CHK_DEFAULT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,97,81,58,10
+ CTEXT "(Lower ranks are preferred)",IDC_STATIC,51,99,162,8
+END
+
+IDD_HISTORY DIALOGEX 0, 0, 287, 109
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Copy subcontact history to MetaContact when creating or adding",IDC_CHK_COPYHISTORY,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,23,258,10
+ RTEXT "Number of days to copy (0=all):",IDC_STATIC,13,37,125,8
+ EDITTEXT IDC_ED_DAYS,158,35,31,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "Keep MetaContact history synchronized with subcontacts",IDC_CHK_METAHISTORY,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,60,258,10
+ CONTROL "Keep subcontact history synchronized with MetaContact",IDC_CHK_SUBHISTORY,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,78,258,10
+ GROUPBOX "History (** beware - change at your own risk **)",IDC_STATIC,7,7,273,95,WS_GROUP
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -291,4 +330,3 @@ IDI_MCSETDEFAULT ICON "meta_set_as_default.ico"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
-
diff --git a/metacontacts/meta_options.c b/metacontacts/meta_options.c
index 8e0c77a..6af47fd 100644
--- a/metacontacts/meta_options.c
+++ b/metacontacts/meta_options.c
@@ -303,3 +303,324 @@ int Meta_ReadOptions(MetaOptions *opt) {
return 0;
}
+/*
+#define ID_STATUS_OFFLINE 40071 ->8
+#define ID_STATUS_ONLINE 40072 ->0
+#define ID_STATUS_AWAY 40073 ->4
+#define ID_STATUS_DND 40074 ->7
+#define ID_STATUS_NA 40075 ->6
+#define ID_STATUS_OCCUPIED 40076 ->5
+#define ID_STATUS_FREECHAT 40077 ->1
+#define ID_STATUS_INVISIBLE 40078 ->0
+#define ID_STATUS_ONTHEPHONE 40079 ->2
+#define ID_STATUS_OUTTOLUNCH 40080 ->3
+*/
+
+int status_order[10] = {8, 0, 4, 7, 6, 5, 1, 0, 2, 3};
+
+int GetDefaultPrio(int status) {
+ return status_order[status - ID_STATUS_OFFLINE];
+}
+
+typedef struct {
+ int prio[10]; // priority for each status
+ BOOL def[10]; // use default for this one?
+} ProtoStatusPrio;
+
+ProtoStatusPrio *priorities = 0;
+
+int GetRealPriority(char *proto, int status) {
+ char szSetting[256];
+ if(!proto) {
+ mir_snprintf(szSetting, 256, "DefaultPrio_%d", status);
+ return DBGetContactSettingWord(0, META_PROTO, szSetting, GetDefaultPrio(status));
+ } else {
+ int prio;
+ mir_snprintf(szSetting, 256, "ProtoPrio_%s%d", proto, status);
+ prio = DBGetContactSettingWord(0, META_PROTO, szSetting, 0xFFFF);
+ if(prio == 0xFFFF) {
+ mir_snprintf(szSetting, 256, "DefaultPrio_%d", status);
+ return DBGetContactSettingWord(0, META_PROTO, szSetting, GetDefaultPrio(status));
+ } else
+ return prio;
+ }
+ return 0xFFFF;
+}
+
+void ReadPriorities() {
+ int num_protocols;
+ PROTOCOLDESCRIPTOR **pppDesc;
+ char szSetting[256];
+ ProtoStatusPrio * current;
+ int i, j;
+
+ CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&num_protocols, (WPARAM)&pppDesc);
+
+ current = priorities = (ProtoStatusPrio *)malloc((num_protocols + 1) * sizeof(ProtoStatusPrio));
+ for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ mir_snprintf(szSetting, 256, "DefaultPrio_%d", i);
+ current->def[i - ID_STATUS_OFFLINE] = TRUE;
+ current->prio[i - ID_STATUS_OFFLINE] = DBGetContactSettingWord(0, META_PROTO, szSetting, GetDefaultPrio(i));
+ }
+ for(i = 0; i < num_protocols; i++) {
+ current = priorities + (i + 1);
+ for(j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) {
+ mir_snprintf(szSetting, 256, "ProtoPrio_%s%d", pppDesc[i]->szName, j);
+ current->prio[j - ID_STATUS_OFFLINE] = DBGetContactSettingWord(0, META_PROTO, szSetting, 0xFFFF);
+ current->def[j - ID_STATUS_OFFLINE] = (current->prio[j - ID_STATUS_OFFLINE] == 0xFFFF);
+ }
+ }
+}
+
+void WritePriorities() {
+ int num_protocols;
+ PROTOCOLDESCRIPTOR **pppDesc;
+ char szSetting[256];
+ ProtoStatusPrio * current = priorities;
+ int i, j;
+
+ CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&num_protocols, (WPARAM)&pppDesc);
+
+ for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ mir_snprintf(szSetting, 256, "DefaultPrio_%d", i);
+ if(current->prio[i - ID_STATUS_OFFLINE] != GetDefaultPrio(i))
+ DBWriteContactSettingWord(0, META_PROTO, szSetting, current->prio[i - ID_STATUS_OFFLINE]);
+ else
+ DBDeleteContactSetting(0, META_PROTO, szSetting);
+ }
+ for(i = 0; i < num_protocols; i++) {
+ current = priorities + (i + 1);
+ for(j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) {
+ mir_snprintf(szSetting, 256, "ProtoPrio_%s%d", pppDesc[i]->szName, j);
+ if(!current->def[j - ID_STATUS_OFFLINE])
+ DBWriteContactSettingWord(0, META_PROTO, szSetting, current->prio[j - ID_STATUS_OFFLINE]);
+ else
+ DBDeleteContactSetting(0, META_PROTO, szSetting);
+ }
+ }
+}
+
+int GetIsDefault(int proto_index, int status) {
+ return (priorities + (proto_index + 1))->def[status - ID_STATUS_OFFLINE];
+}
+
+BOOL GetPriority(int proto_index, int status) {
+ ProtoStatusPrio * current;
+ if(proto_index == -1) {
+ current = priorities;
+ return current->prio[status - ID_STATUS_OFFLINE];
+ } else {
+ current = priorities + (proto_index + 1);
+ if(current->def[status - ID_STATUS_OFFLINE]) {
+ current = priorities;
+ }
+ return current->prio[status - ID_STATUS_OFFLINE];
+ }
+ return 0xFFFF;
+}
+
+void SetPriority(int proto_index, int status, BOOL def, int prio) {
+ ProtoStatusPrio * current;
+ if(prio < 0) prio = 0;
+ if(prio > 500) prio = 500;
+ if(proto_index == -1) {
+ current = priorities;
+ current->prio[status - ID_STATUS_OFFLINE] = prio;
+ } else {
+ current = priorities + (proto_index + 1);
+ current->def[status - ID_STATUS_OFFLINE] = def;
+ if(!def) {
+ current->prio[status - ID_STATUS_OFFLINE] = prio;
+ }
+ }
+}
+
+void ResetPriorities() {
+ int num_protocols;
+ PROTOCOLDESCRIPTOR **pppDesc;
+ ProtoStatusPrio * current;
+ int i, j;
+
+ CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&num_protocols, (WPARAM)&pppDesc);
+
+ current = priorities;
+ for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ current->def[i - ID_STATUS_OFFLINE] = TRUE;
+ current->prio[i - ID_STATUS_OFFLINE] = GetDefaultPrio(i);
+ }
+ for(i = 0; i < num_protocols; i++) {
+ current = priorities + (i + 1);
+ for(j = ID_STATUS_OFFLINE; j <= ID_STATUS_OUTTOLUNCH; j++) {
+ current->def[j - ID_STATUS_OFFLINE] = TRUE;
+ }
+ }
+}
+
+#define WMU_FILLSTATUSCMB (WM_USER + 0x100)
+#define WMU_FILLPRIODATA (WM_USER + 0x101)
+
+BOOL CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ HWND hw;
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+ SendMessage(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 0));
+ ReadPriorities();
+ {
+ int num_protocols;
+ PROTOCOLDESCRIPTOR **pppDesc;
+ int i, index;
+
+ CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&num_protocols, (WPARAM)&pppDesc);
+ hw = GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL);
+ index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)Translate("<default>"));
+ SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, -1);
+ for(i = 0; i < num_protocols; i++) {
+ if(pppDesc[i]->type == PROTOTYPE_PROTOCOL) {
+ if(strcmp(pppDesc[i]->szName, META_PROTO) != 0) {
+ index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)pppDesc[i]->szName);
+ SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i);
+ }
+ }
+ }
+
+ SendMessage(hw, CB_SETCURSEL, 0, 0);
+ SendMessage(hwndDlg, WMU_FILLSTATUSCMB, 0, 0);
+ SendMessage(hwndDlg, WMU_FILLPRIODATA, 0, 0);
+ }
+ return FALSE;
+ case WMU_FILLPRIODATA:
+ {
+ int sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0);
+ sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0);
+ SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE);
+ if(index == -1) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), TRUE);
+ CheckDlgButton(hwndDlg, IDC_CHK_DEFAULT, TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DEFAULT), FALSE);
+ } else {
+ if(GetIsDefault(index, status)) {
+ CheckDlgButton(hwndDlg, IDC_CHK_DEFAULT, TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), FALSE);
+ } else {
+ CheckDlgButton(hwndDlg, IDC_CHK_DEFAULT, FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), TRUE);
+ }
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DEFAULT), TRUE);
+ }
+ }
+ }
+ }
+ return TRUE;
+ case WMU_FILLSTATUSCMB:
+ {
+ int sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0);
+ HWND hw = GetDlgItem(hwndDlg, IDC_CMB_STATUS);
+ SendMessage(hw, CB_RESETCONTENT, 0, 0);
+ if(index == -1) {
+ int i;
+ for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)(char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, i, 0));
+ SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i);
+ }
+ } else {
+ int num_protocols, caps, i;
+ PROTOCOLDESCRIPTOR **pppDesc;
+ CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&num_protocols, (WPARAM)&pppDesc);
+
+ caps = CallProtoService(pppDesc[index]->szName, PS_GETCAPS, PFLAGNUM_2, 0);
+
+ for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ if(caps & Proto_Status2Flag(i)) {
+ index = SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)(char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, i, 0));
+ SendMessage(hw, CB_SETITEMDATA, (WPARAM)index, i);
+ }
+ }
+ }
+ SendMessage(hw, CB_SETCURSEL, 0, 0);
+ SendMessage(hwndDlg, WMU_FILLPRIODATA, 0, 0);
+ }
+ }
+ return TRUE;
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == BN_CLICKED ) {
+ switch( LOWORD( wParam )) {
+ case IDC_CHK_DEFAULT:
+ {
+ int sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0);
+ sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHK_DEFAULT);
+ int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0);
+ SetPriority(index, status, checked, GetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, 0, FALSE));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PRIORITY), !checked);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SP_PRIORITY), !checked);
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ }
+ }
+ break;
+ case IDC_BTN_RESET:
+ ResetPriorities();
+ SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_SETCURSEL, 0, 0);
+ SendMessage(hwndDlg, WMU_FILLSTATUSCMB, 0, 0);
+ SendMessage(hwndDlg, WMU_FILLPRIODATA, 0, 0);
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ }
+ }
+ if ( HIWORD( wParam ) == EN_CHANGE && LOWORD(wParam) == IDC_ED_PRIORITY && ( HWND )lParam == GetFocus()) {
+ int sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ int index = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_PROTOCOL), CB_GETITEMDATA, (WPARAM)sel, 0);
+ sel = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ int status = SendMessage(GetDlgItem(hwndDlg, IDC_CMB_STATUS), CB_GETITEMDATA, (WPARAM)sel, 0);
+ int prio = GetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, 0, FALSE);
+ SetPriority(index, status, FALSE, prio);
+ if(prio != GetPriority(index, status))
+ SetDlgItemInt(hwndDlg, IDC_ED_PRIORITY, GetPriority(index, status), FALSE);
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ }
+ }
+ if ( HIWORD( wParam ) == CBN_SELCHANGE) {
+ switch( LOWORD( wParam )) {
+ case IDC_CMB_STATUS:
+ SendMessage(hwndDlg, WMU_FILLPRIODATA, 0, 0);
+ break;
+ case IDC_CMB_PROTOCOL:
+ SendMessage(hwndDlg, WMU_FILLSTATUSCMB, 0, 0);
+ break;
+ }
+ }
+ break;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
+ WritePriorities();
+ return TRUE;
+ }
+ break;
+ case WM_DESTROY:
+ free(priorities);
+ priorities = 0;
+ break;
+ }
+
+ return FALSE;
+}
diff --git a/metacontacts/meta_services.c b/metacontacts/meta_services.c
index b2a9ed7..f24efda 100644
--- a/metacontacts/meta_services.c
+++ b/metacontacts/meta_services.c
@@ -1848,19 +1848,31 @@ int Meta_GetInfo(WPARAM wParam, LPARAM lParam) {
int Meta_OptInit(WPARAM wParam, LPARAM lParam) {
OPTIONSDIALOGPAGE odp;
ZeroMemory(&odp, sizeof(odp));
-#define OPTIONPAGE_OLD_SIZE2 60
- //odp.cbSize = sizeof(odp);
- odp.cbSize = OPTIONPAGE_OLD_SIZE2;
+ odp.cbSize = sizeof(odp);
odp.position = -790000000;
odp.hInstance = hInstance;
+ odp.flags = ODPF_BOLDGROUPS;
+
odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS);
odp.pszTitle = Translate("MetaContacts");
odp.pszGroup = Translate("Contact List");
- odp.flags = ODPF_BOLDGROUPS;
- odp.nIDBottomSimpleControl = 0;
+ odp.pszTab = Translate("General");
odp.pfnDlgProc = DlgProcOpts;
CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+ odp.pszTemplate = MAKEINTRESOURCE(IDD_PRIORITIES);
+ odp.pszTitle = Translate("MetaContacts");
+ odp.pszGroup = Translate("Contact List");
+ odp.pszTab = Translate("Priorities");
+ odp.pfnDlgProc = DlgProcOptsPriorities;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ odp.pszTemplate = MAKEINTRESOURCE(IDD_HISTORY);
+ odp.pszTitle = Translate("MetaContacts");
+ odp.pszGroup = Translate("Contact List");
+ odp.pszTab = Translate("History");
+ odp.pfnDlgProc = DlgProcOpts;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
return 0;
}
diff --git a/metacontacts/meta_utils.c b/metacontacts/meta_utils.c
index c368ebb..7d064e1 100644
--- a/metacontacts/meta_utils.c
+++ b/metacontacts/meta_utils.c
@@ -429,23 +429,6 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default)
return TRUE;
}
-/*
-#define ID_STATUS_OFFLINE 40071 ->8
-#define ID_STATUS_ONLINE 40072 ->0
-#define ID_STATUS_AWAY 40073 ->4
-#define ID_STATUS_DND 40074 ->7
-#define ID_STATUS_NA 40075 ->6
-#define ID_STATUS_OCCUPIED 40076 ->5
-#define ID_STATUS_FREECHAT 40077 ->1
-#define ID_STATUS_INVISIBLE 40078 ->0
-#define ID_STATUS_ONTHEPHONE 40079 ->2
-#define ID_STATUS_OUTTOLUNCH 40080 ->3
-
-* Treat AIM 'away' as NA, to prevent it from being the most online all the time - see code in GetMostOnline below
-
-*/
-
-int status_order[10] = {8, 0, 4, 7, 6, 5, 1, 0, 2, 3};
/**
* Convenience method - get most online contact supporting messaging
@@ -467,7 +450,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca
HANDLE most_online_contact = NULL, hContact;
int i, status, default_contact_number, num_contacts;
unsigned long caps = 0;
- char *proto;
+ char *proto, *most_online_proto;
// you can't get more online than having the default contact ONLINE - so check that first
if((default_contact_number = DBGetContactSettingDword(hMeta,META_PROTO,"Default",(DWORD)-1)) == (DWORD)-1)
@@ -491,7 +474,6 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca
// a subcontact is being temporarily 'forced' to do sending
if((most_online_contact = (HANDLE)DBGetContactSettingDword(hMeta, META_PROTO, "ForceSend", 0))) {
- proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online_contact, 0);
caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0;
if(proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM;
if(proto && (caps & capability) == capability && capability != 0) // capability is 0 when we're working out status
@@ -516,6 +498,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca
} else
most_online_status = ID_STATUS_OFFLINE;
+ most_online_proto = proto;
// otherwise, check all the subcontacts for the one closest to the ONLINE state which supports the required capability
for(i = 0; i < num_contacts; i++) {
if(i == default_contact_number) // already checked that (i.e. initial value of most_online_contact and most_online_status are those of the default contact)
@@ -533,24 +516,17 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca
status = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE);
- // see comment above function - AIM is disproportionatly the most online due to limited status modes
- if((strcmp(proto, "AIM") == 0
- || strcmp(proto, "SAMETIME") == 0
- || strcmp(proto, "MYSPACE"))
- && status == ID_STATUS_AWAY)
- {
- status = ID_STATUS_NA;
- }
-
if(status == ID_STATUS_ONLINE) {
most_online_contact = hContact;
+ most_online_proto = proto;
return most_online_contact;
} else if(status <= ID_STATUS_OFFLINE) // status below ID_STATUS_OFFLINE is a connecting status
continue;
else {
- if(status_order[status - ID_STATUS_OFFLINE] < status_order[most_online_status - ID_STATUS_OFFLINE]) {
+ if(GetRealPriority(proto, status) < GetRealPriority(most_online_proto, most_online_status)) {
most_online_status = status;
most_online_contact = hContact;
+ most_online_proto = proto;
}
}
}
diff --git a/metacontacts/metacontacts.h b/metacontacts/metacontacts.h
index ba08edc..ba0d207 100644
--- a/metacontacts/metacontacts.h
+++ b/metacontacts/metacontacts.h
@@ -29,6 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define _WIN32_WINNT 0x0400
#define _WIN32_IE 0x0300
+#define MIRANDA_VER 0x0600
+
#include <windows.h>
#include <winsock.h>
#include <winbase.h>
@@ -206,9 +208,13 @@ typedef struct tag_MetaOptions {
extern MetaOptions options;
BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+BOOL CALLBACK DlgProcOptsPriorities(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
int Meta_WriteOptions(MetaOptions *opt);
int Meta_ReadOptions(MetaOptions *opt);
+int GetDefaufaultPrio(int status);
+int GetRealPriority(char *proto, int status);
+
// API function headers
int MetaAPI_GetMeta(WPARAM wParam, LPARAM lParam);
int MetaAPI_GetDefault(WPARAM wParam, LPARAM lParam);
diff --git a/metacontacts/resource.h b/metacontacts/resource.h
index 575bc1b..0639c6d 100644
--- a/metacontacts/resource.h
+++ b/metacontacts/resource.h
@@ -16,6 +16,9 @@
#define IDI_MCADD 121
#define IDI_ICON1 122
#define IDI_MCSETDEFAULT 122
+#define IDD_PRIORITIES 123
+#define IDD_DIALOG1 124
+#define IDD_HISTORY 124
#define IDC_METALIST 1002
#define IDC_ONLYAVAIL 1005
#define IDC_DEFAULT 1008
@@ -28,6 +31,7 @@
#define IDC_CHK_SUPPRESSSTATUS 1018
#define IDC_CHK_FORCEDEFAULT 1018
#define IDC_CHK_SRT 1018
+#define IDC_CHK_DEFAULT 1018
#define IDC_RAD_UID 1019
#define IDC_RAD_DID 1020
#define IDC_RAD_MSG 1021
@@ -53,15 +57,20 @@
#define IDC_CHK_COPYDATA 1038
#define IDC_CHK_LOCKHANDLE 1039
#define IDC_CHK_TEMPDEFAULT 1040
-#define IDC_STATIC -1
+#define IDC_ED_PRIORITY 1042
+#define IDC_SP_PRIORITY 1043
+#define IDC_CMB_STATUS 1044
+#define IDC_BUTTON2 1048
+#define IDC_BTN_RESET 1048
+#define IDC_CMB_PROTOCOL 1062
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 123
+#define _APS_NEXT_RESOURCE_VALUE 125
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1042
+#define _APS_NEXT_CONTROL_VALUE 1049
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/metacontacts/version.h b/metacontacts/version.h
index 6e2f65b..a566f67 100644
--- a/metacontacts/version.h
+++ b/metacontacts/version.h
@@ -3,9 +3,9 @@
// take effect within the version resource)
#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 13
+#define __MINOR_VERSION 14
#define __RELEASE_NUM 0
-#define __BUILD_NUM 9
+#define __BUILD_NUM 0
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM