summaryrefslogtreecommitdiff
path: root/plugins/SkypeStatusChange
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SkypeStatusChange')
-rw-r--r--plugins/SkypeStatusChange/src/main.cpp39
-rw-r--r--plugins/SkypeStatusChange/src/options.cpp346
-rw-r--r--plugins/SkypeStatusChange/src/stdafx.h80
3 files changed, 166 insertions, 299 deletions
diff --git a/plugins/SkypeStatusChange/src/main.cpp b/plugins/SkypeStatusChange/src/main.cpp
index e1ce328a51..3be15c1351 100644
--- a/plugins/SkypeStatusChange/src/main.cpp
+++ b/plugins/SkypeStatusChange/src/main.cpp
@@ -32,19 +32,35 @@ static PLUGININFOEX pluginInfoEx =
{ 0x2925520b, 0x6677, 0x4658, { 0x8b, 0xad, 0x56, 0x61, 0xd1, 0x3e, 0x46, 0x92 }}
};
+static int CompareStatuses(const PrevStatus *p1, const PrevStatus *p2)
+{
+ return mir_strcmp(p1->szProto, p2->szProto);
+}
+
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>("Change Skype Status", pluginInfoEx)
+ PLUGIN<CMPlugin>("Change Skype Status", pluginInfoEx),
+ m_aProtocol2Status(3, CompareStatuses),
+ bSyncStatusMsg(getModule(), "SyncStatusMsg", false),
+ bSyncStatusState(getModule(), "SyncStatusState", false)
{}
/////////////////////////////////////////////////////////////////////////////////////////
enum
{
- SKYPECONTROLAPI_ATTACH_SUCCESS = 0, // Client is successfully attached and API window handle can be found in wParam parameter
- SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, // Skype has acknowledged connection request and is waiting for confirmation from the user.
+ // Client is successfully attached and API window handle can be found in wParam parameter
+ SKYPECONTROLAPI_ATTACH_SUCCESS = 0,
+
+ // Skype has acknowledged connection request and is waiting for confirmation from the user.
+ SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1,
+
// The client is not yet attached and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message
- SKYPECONTROLAPI_ATTACH_REFUSED = 2, // User has explicitly denied access to client
- SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, // API is not available at the moment. For example, this happens when no user is currently logged in.
+ // User has explicitly denied access to client
+ SKYPECONTROLAPI_ATTACH_REFUSED = 2,
+
+ // API is not available at the moment. For example, this happens when no user is currently logged in.
+ SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3,
+
// Client should wait for SKYPECONTROLAPI_ATTACH_API_AVAILABLE broadcast before making any further
// connection attempts.
SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
@@ -88,7 +104,6 @@ private:
size_t m_nStatusIndex;
};
-COptions g_Options;
CStatusInfo g_CurrStatusInfo;
mir_cs g_csStatusInfo;
@@ -101,15 +116,15 @@ int SSC_OnProtocolAck(WPARAM, LPARAM lParam)
if (pAckData->type != ACKTYPE_STATUS || pAckData->result != ACKRESULT_SUCCESS || !pAckData->szModule)
return 0;
- if (!g_Options.IsProtocolExcluded(pAckData->szModule)) {
+ if (!g_plugin.IsProtocolExcluded(pAckData->szModule)) {
int nStatus = Proto_GetStatus(pAckData->szModule);
for (size_t i = 0; i < _countof(g_aStatusCode); ++i) {
const CMirandaStatus2SkypeStatus& ms = g_aStatusCode[i];
if (ms.m_nMirandaStatus == nStatus) {
int nPrevStatus;
- if ((false == g_Options.IsProtocolStatusExcluded(pAckData->szModule, nStatus))
- && ((false == g_Options.GetSyncStatusStateFlag())
- || (false == g_Options.GetPreviousStatus(pAckData->szModule, nPrevStatus))
+ if ((false == g_plugin.IsProtocolStatusExcluded(pAckData->szModule, nStatus))
+ && ((!g_plugin.bSyncStatusState)
+ || (false == g_plugin.GetPreviousStatus(pAckData->szModule, nPrevStatus))
|| (nPrevStatus != nStatus))) {
{
mir_cslock guard(g_csStatusInfo);
@@ -121,7 +136,7 @@ int SSC_OnProtocolAck(WPARAM, LPARAM lParam)
g_CurrStatusInfo.StatusIndex(INVALID_INDEX);
g_CurrStatusInfo.Module(nullptr);
}
- else g_Options.SetPreviousStatus(pAckData->szModule, nStatus);
+ else g_plugin.SetPreviousStatus(pAckData->szModule, nStatus);
}
break;
}
@@ -189,7 +204,7 @@ LRESULT APIENTRY SkypeAPI_WindowProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
oCopyData.lpData = szSkypeCmd;
oCopyData.cbData = cLength + 1;
SendMessage(wndSkypeAPIWindow, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&oCopyData);
- if (g_Options.GetSyncStatusMsgFlag()) {
+ if (g_plugin.bSyncStatusMsg) {
wchar_t* pszStatusMsg = nullptr;
if (ProtoServiceExists(si.Module(), PS_GETMYAWAYMSG))
pszStatusMsg = reinterpret_cast<wchar_t*>(CallProtoService(si.Module(), PS_GETMYAWAYMSG, (WPARAM)ms.m_nMirandaStatus, SGMA_UNICODE));
diff --git a/plugins/SkypeStatusChange/src/options.cpp b/plugins/SkypeStatusChange/src/options.cpp
index a0e65a3c8e..f132ecd6db 100644
--- a/plugins/SkypeStatusChange/src/options.cpp
+++ b/plugins/SkypeStatusChange/src/options.cpp
@@ -5,262 +5,149 @@
struct CTreeItemData
{
- enum EType
- {
- Protocol,
- Status
- };
-
- EType m_nType;
+ bool m_isProtocol;
char *m_pszModule;
- int m_nStatus;
-};
-
-enum ETreeCheckBoxState
-{
- // tree check box state
- TCBS_NOSTATEBOX = 0,
- TCBS_UNCHECKED = 1,
- TCBS_CHECKED = 2,
- TCBS_DISABLE_UNCHECKED = 3,
- TCBS_DISABLE_CHECKED = 4,
+ int m_nStatus;
};
-HTREEITEM tree_insert_item(HWND hwndTree, wchar_t *pName, HTREEITEM htiParent, ETreeCheckBoxState nState, CTreeItemData *pData)
+class CSettingsDlg : public CDlgBase
{
- TVINSERTSTRUCT tvi = {};
- tvi.hParent = htiParent;
- tvi.hInsertAfter = TVI_LAST;
- tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
- tvi.item.pszText = pName;
- tvi.item.lParam = reinterpret_cast<LPARAM>(pData);
- tvi.item.stateMask = TVIS_STATEIMAGEMASK;
- tvi.item.state = INDEXTOSTATEIMAGEMASK(nState);
- return TreeView_InsertItem(hwndTree, &tvi);
-}
-
-void InitProtocolTree(HWND hwndTreeCtrl)
-{
- enum { OFFLINE_STATUS_INDEX = 5 };
+ CCtrlCheck chkMsg, chkState;
+ CCtrlTreeView m_tree;
- for (auto &pAccount : Accounts()) {
- CTreeItemData *pItemData = new CTreeItemData;
- pItemData->m_nType = CTreeItemData::Protocol;
- pItemData->m_pszModule = pAccount->szModuleName;
-
- bool bProtocolExcluded = g_Options.IsProtocolExcluded(pAccount->szModuleName);
- HTREEITEM hti = tree_insert_item(hwndTreeCtrl, pAccount->tszAccountName, TVI_ROOT, ((true == bProtocolExcluded) ? TCBS_CHECKED : TCBS_UNCHECKED), pItemData);
- if (hti) {
- int nStatusBits = CallProtoService(pAccount->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
- int nStatusExcluded = CallProtoService(pAccount->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0);
- pItemData = new CTreeItemData;
- pItemData->m_nType = CTreeItemData::Status;
- pItemData->m_pszModule = pAccount->szModuleName;
- pItemData->m_nStatus = ID_STATUS_OFFLINE;
- bool bStatusExcluded = g_Options.IsProtocolStatusExcluded(pAccount->szModuleName, pItemData->m_nStatus);
- ETreeCheckBoxState nState = TCBS_UNCHECKED;
- if (bProtocolExcluded) {
- if (bStatusExcluded)
- nState = TCBS_DISABLE_CHECKED;
- else
- nState = TCBS_DISABLE_UNCHECKED;
- }
- else {
- if (bStatusExcluded)
- nState = TCBS_CHECKED;
- else
- nState = TCBS_UNCHECKED;
- }
- tree_insert_item(hwndTreeCtrl, TranslateW(g_aStatusCode[OFFLINE_STATUS_INDEX].m_ptszStatusName), hti, nState, pItemData);
- for (size_t k = 0; k < _countof(g_aStatusCode); ++k) {
- const CMirandaStatus2SkypeStatus &m2s = g_aStatusCode[k];
- unsigned long statusFlags = Proto_Status2Flag(m2s.m_nMirandaStatus);
- if ((m2s.m_nMirandaStatus != ID_STATUS_OFFLINE) && (nStatusBits & statusFlags) && !(nStatusExcluded & statusFlags)) {
- pItemData = new CTreeItemData;
- pItemData->m_nType = CTreeItemData::Status;
- pItemData->m_pszModule = pAccount->szModuleName;
- pItemData->m_nStatus = m2s.m_nMirandaStatus;
- bStatusExcluded = g_Options.IsProtocolStatusExcluded(pAccount->szModuleName, pItemData->m_nStatus);
- if (bProtocolExcluded) {
- if (bStatusExcluded)
- nState = TCBS_DISABLE_CHECKED;
- else
- nState = TCBS_DISABLE_UNCHECKED;
- }
- else {
- if (bStatusExcluded)
- nState = TCBS_CHECKED;
- else
- nState = TCBS_UNCHECKED;
- }
-
- tree_insert_item(hwndTreeCtrl, TranslateW(m2s.m_ptszStatusName), hti, nState, pItemData);
- }
- }
+ void DisableChildren(HTREEITEM htiParent, int iState)
+ {
+ TVITEMEX tvi = {};
+ tvi.mask = TVIF_STATE;
+ tvi.stateMask = TVIS_STATEIMAGEMASK;
+ if (iState == 1) {
+ tvi.mask |= TVIF_STATEEX;
+ tvi.uStateEx = TVIS_EX_DISABLED;
+ tvi.state = INDEXTOSTATEIMAGEMASK(2);
+ }
+ else tvi.state = INDEXTOSTATEIMAGEMASK(1);
- TreeView_Expand(hwndTreeCtrl, hti, TVE_EXPAND);
+ for (HTREEITEM hti = m_tree.GetChild(htiParent); hti; hti = m_tree.GetNextSibling(hti)) {
+ tvi.hItem = hti;
+ m_tree.SetItem(&tvi);
}
}
-}
-inline HTREEITEM tree_get_child_item(HWND hwndTreeCtrl, HTREEITEM hti)
-{
- return TreeView_GetChild(hwndTreeCtrl, hti);
-}
-
-inline HTREEITEM tree_get_next_sibling_item(HWND hwndTreeCtrl, HTREEITEM hti)
-{
- return TreeView_GetNextSibling(hwndTreeCtrl, hti);
-}
-
-const CTreeItemData *get_item_data(HWND hwndTreeCtrl, HTREEITEM hti)
-{
- TVITEM tvi = { 0 };
- tvi.hItem = hti;
- tvi.mask = TVIF_PARAM | TVIF_HANDLE;
- if (TRUE == ::SendMessage(hwndTreeCtrl, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvi))) {
- CTreeItemData *pData = reinterpret_cast<CTreeItemData *>(tvi.lParam);
- return pData;
+ void FreeMemory(HTREEITEM hti)
+ {
+ for (HTREEITEM h = m_tree.GetChild(hti); h; h = m_tree.GetNextSibling(h)) {
+ FreeMemory(h);
+ CTreeItemData *pData = GetItemData(h);
+ if (pData)
+ delete pData;
+ }
}
- return nullptr;
-}
-
-inline ETreeCheckBoxState tree_get_state_image(HWND hwndTree, HTREEITEM hti)
-{
- TVITEM tvi;
- tvi.hItem = hti;
- tvi.mask = TVIF_STATE | TVIF_HANDLE;
- tvi.stateMask = TVIS_STATEIMAGEMASK;
- if (TRUE == ::SendMessage(hwndTree, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvi))) {
- UINT nState = (tvi.state >> 12);
- return static_cast<ETreeCheckBoxState>(nState);
+ CTreeItemData* GetItemData(HTREEITEM hti)
+ {
+ TVITEMEX tvi = {};
+ tvi.hItem = hti;
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE;
+ return (m_tree.GetItem(&tvi)) ? (CTreeItemData *)tvi.lParam : nullptr;
}
- assert(!"we should never get here!");
- return TCBS_UNCHECKED;
-}
-
-void FreeMemory(HWND hwndTreeCtrl, HTREEITEM hti)
-{
- for (HTREEITEM h = tree_get_child_item(hwndTreeCtrl, hti); h; h = tree_get_next_sibling_item(hwndTreeCtrl, h)) {
- FreeMemory(hwndTreeCtrl, h);
- const CTreeItemData *pData = get_item_data(hwndTreeCtrl, h);
- if (pData)
- delete pData;
- }
-}
-
-bool tree_set_item_state(HWND hwndTree, HTREEITEM hti, ETreeCheckBoxState nState)
-{
- TVITEM tvi;
- memset(&tvi, 0, sizeof(tvi));
-
- tvi.mask = TVIF_STATE | TVIF_HANDLE;
- tvi.hItem = hti;
-
- tvi.stateMask = TVIS_STATEIMAGEMASK;
- tvi.state = INDEXTOSTATEIMAGEMASK(nState);
-
- return TRUE == ::SendMessage(hwndTree, TVM_SETITEM, 0, reinterpret_cast<LPARAM>(&tvi));
-}
-
-void disable_children(HWND hwndTree, HTREEITEM htiParent, bool bDisable)
-{
- for (HTREEITEM hti = tree_get_child_item(hwndTree, htiParent); hti; hti = tree_get_next_sibling_item(hwndTree, hti)) {
- ETreeCheckBoxState nState = tree_get_state_image(hwndTree, hti);
- if (bDisable) {
- if (TCBS_CHECKED == nState)
- nState = TCBS_DISABLE_CHECKED;
- else if (TCBS_UNCHECKED == nState)
- nState = TCBS_DISABLE_UNCHECKED;
- }
- else {
- if (TCBS_DISABLE_CHECKED == nState)
- nState = TCBS_CHECKED;
- else if (TCBS_DISABLE_UNCHECKED == nState)
- nState = TCBS_UNCHECKED;
+ void SaveExclusion(HTREEITEM htiParent)
+ {
+ for (HTREEITEM hti = m_tree.GetChild(htiParent); hti; hti = m_tree.GetNextSibling(hti)) {
+ CTreeItemData *pData = GetItemData(hti);
+ bool isChecked = m_tree.IsSelected(hti);
+ if (pData->m_isProtocol) {
+ g_plugin.ExcludeProtocol(pData->m_pszModule, isChecked);
+ SaveExclusion(hti);
+ }
+ else g_plugin.ExcludeProtocolStatus(pData->m_pszModule, pData->m_nStatus, isChecked);
}
- tree_set_item_state(hwndTree, hti, nState);
}
-}
-void save_exclusion_list(HWND hwndTree, HTREEITEM htiParent)
-{
- for (HTREEITEM hti = tree_get_child_item(hwndTree, htiParent); hti; hti = tree_get_next_sibling_item(hwndTree, hti)) {
- const CTreeItemData *pData = get_item_data(hwndTree, hti);
- ETreeCheckBoxState nState = tree_get_state_image(hwndTree, hti);
- if (CTreeItemData::Protocol == pData->m_nType) {
- g_Options.ExcludeProtocol(pData->m_pszModule, TCBS_CHECKED == nState);
- save_exclusion_list(hwndTree, hti);
- }
- else g_Options.ExcludeProtocolStatus(pData->m_pszModule, pData->m_nStatus, ((TCBS_CHECKED == nState) || (TCBS_DISABLE_CHECKED == nState)));
+ HTREEITEM TreeInsert(wchar_t *pName, HTREEITEM htiParent, bool bSelected, CTreeItemData *pData)
+ {
+ TVINSERTSTRUCT tvi = {};
+ tvi.hParent = htiParent;
+ tvi.hInsertAfter = TVI_LAST;
+ tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
+ tvi.item.pszText = pName;
+ tvi.item.lParam = reinterpret_cast<LPARAM>(pData);
+ tvi.item.stateMask = TVIS_SELECTED;
+ tvi.item.state = (bSelected) ? TVIS_SELECTED : 0;
+ return m_tree.InsertItem(&tvi);
}
-}
-
-static INT_PTR CALLBACK SettingsDlgProc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
-{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hdlg);
- InitProtocolTree(GetDlgItem(hdlg, IDC_TREE_PROTOCOLS));
-
- CheckDlgButton(hdlg, IDC_CHECK_SYNCK_STATUS_MSG, (g_Options.GetSyncStatusMsgFlag()) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_STATUSES, (g_Options.GetSyncStatusStateFlag()) ? BST_CHECKED : BST_UNCHECKED);
- return TRUE;
-
- case WM_NOTIFY:
- {
- LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lp);
- switch (pNMHDR->code) {
- case PSN_APPLY:
- save_exclusion_list(GetDlgItem(hdlg, IDC_TREE_PROTOCOLS), TVI_ROOT);
- g_Options.SetSyncStatusMsgFlag(1 == IsDlgButtonChecked(hdlg, IDC_CHECK_SYNCK_STATUS_MSG));
- g_Options.SetSyncStatusStateFlag(1 == IsDlgButtonChecked(hdlg, IDC_CHECK_STATUSES));
- break;
-
- case NM_CLICK:
- if (IDC_TREE_PROTOCOLS == wp) {
- uint32_t pos = ::GetMessagePos();
-
- HWND hwndTree = ::GetDlgItem(hdlg, IDC_TREE_PROTOCOLS);
+public:
+ CSettingsDlg() :
+ CDlgBase(g_plugin, IDD_DIALOG_SETTINGS),
+ m_tree(this, IDC_TREE_PROTOCOLS),
+ chkMsg(this, IDC_CHECK_SYNCK_STATUS_MSG),
+ chkState(this, IDC_CHECK_STATUSES)
+ {
+ CreateLink(chkMsg, g_plugin.bSyncStatusMsg);
+ CreateLink(chkState, g_plugin.bSyncStatusState);
- TVHITTESTINFO tvhti;
- tvhti.pt.x = LOWORD(pos);
- tvhti.pt.y = HIWORD(pos);
- ::ScreenToClient(hwndTree, &(tvhti.pt));
+ m_tree.OnItemChanged = Callback(this, &CSettingsDlg::onItemChanged_Tree);
+ }
- HTREEITEM hti = reinterpret_cast<HTREEITEM>(::SendMessage(hwndTree, TVM_HITTEST, 0, reinterpret_cast<LPARAM>(&tvhti)));
- if (hti && (tvhti.flags & (TVHT_ONITEMSTATEICON | TVHT_ONITEMICON))) {
- ETreeCheckBoxState nState = tree_get_state_image(hwndTree, hti);
- if (TCBS_CHECKED == nState || TCBS_UNCHECKED == nState) {
- if (TCBS_CHECKED == nState)
- nState = TCBS_UNCHECKED;
- else
- nState = TCBS_CHECKED;
+ bool OnInitDialog() override
+ {
+ for (auto &pAccount : Accounts()) {
+ if (mir_strcmpi(pAccount->szProtoName, "SKYPE")) {
+ g_plugin.ExcludeProtocol(pAccount->szModuleName, true);
+ continue;
+ }
- tree_set_item_state(hwndTree, hti, nState);
- disable_children(hwndTree, hti, TCBS_CHECKED == nState);
- PropSheet_Changed(::GetParent(hdlg), hdlg);
- }
+ CTreeItemData *pItemData = new CTreeItemData;
+ pItemData->m_isProtocol = true;
+ pItemData->m_pszModule = pAccount->szModuleName;
+
+ bool bProtocolExcluded = g_plugin.IsProtocolExcluded(pAccount->szModuleName);
+ HTREEITEM hti = TreeInsert(pAccount->tszAccountName, TVI_ROOT, bProtocolExcluded, pItemData);
+ if (hti) {
+ int nStatusBits = CallProtoService(pAccount->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
+ int nStatusExcluded = CallProtoService(pAccount->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0);
+ pItemData = new CTreeItemData;
+ pItemData->m_isProtocol = false;
+ pItemData->m_pszModule = pAccount->szModuleName;
+ pItemData->m_nStatus = ID_STATUS_OFFLINE;
+ bool bStatusExcluded = g_plugin.IsProtocolStatusExcluded(pAccount->szModuleName, pItemData->m_nStatus);
+ TreeInsert(TranslateW(g_aStatusCode[5].m_ptszStatusName), hti, bStatusExcluded, pItemData);
+ for (size_t k = 0; k < _countof(g_aStatusCode); ++k) {
+ const CMirandaStatus2SkypeStatus &m2s = g_aStatusCode[k];
+ unsigned long statusFlags = Proto_Status2Flag(m2s.m_nMirandaStatus);
+ if ((m2s.m_nMirandaStatus != ID_STATUS_OFFLINE) && (nStatusBits & statusFlags) && !(nStatusExcluded & statusFlags)) {
+ pItemData = new CTreeItemData;
+ pItemData->m_isProtocol = false;
+ pItemData->m_pszModule = pAccount->szModuleName;
+ pItemData->m_nStatus = m2s.m_nMirandaStatus;
+ bStatusExcluded = g_plugin.IsProtocolStatusExcluded(pAccount->szModuleName, pItemData->m_nStatus);
+ TreeInsert(TranslateW(m2s.m_ptszStatusName), hti, bStatusExcluded, pItemData);
}
}
+
+ m_tree.Expand(hti, TVE_EXPAND);
}
}
- break;
+ return true;
+ }
- case WM_COMMAND:
- if (BN_CLICKED == HIWORD(wp) && ((IDC_CHECK_SYNCK_STATUS_MSG == LOWORD(wp)) || (IDC_CHECK_STATUSES == LOWORD(wp))))
- PropSheet_Changed(::GetParent(hdlg), hdlg);
- break;
+ bool OnApply() override
+ {
+ SaveExclusion(TVI_ROOT);
+ return true;
+ }
- case WM_DESTROY:
- FreeMemory(GetDlgItem(hdlg, IDC_TREE_PROTOCOLS), TVI_ROOT);
- break;
+ void OnDestroy() override
+ {
+ FreeMemory(TVI_ROOT);
}
- return FALSE;
-}
+
+ void onItemChanged_Tree(CCtrlTreeView::TEventInfo *ev)
+ {
+ DisableChildren(ev->hItem, m_tree.GetItemState(ev->hItem, TVIS_STATEIMAGEMASK) >> 12);
+ }
+};
int SSC_OptInitialise(WPARAM wp, LPARAM)
{
@@ -268,8 +155,7 @@ int SSC_OptInitialise(WPARAM wp, LPARAM)
odp.position = 910000000;
odp.szTitle.a = LPGEN("Change Skype status");
odp.szGroup.a = LPGEN("Plugins");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_SETTINGS);
- odp.pfnDlgProc = SettingsDlgProc;
+ odp.pDialog = new CSettingsDlg();
g_plugin.addOptions(wp, &odp);
return 0;
}
diff --git a/plugins/SkypeStatusChange/src/stdafx.h b/plugins/SkypeStatusChange/src/stdafx.h
index 97c4d1e730..3a9b5d8242 100644
--- a/plugins/SkypeStatusChange/src/stdafx.h
+++ b/plugins/SkypeStatusChange/src/stdafx.h
@@ -14,15 +14,25 @@
#include <m_langpack.h>
#include <m_utils.h>
+struct PrevStatus
+{
+ PrevStatus(const char *_proto, int _status) :
+ szProto(mir_strdup(_proto)),
+ iStatus(_status)
+ {}
+
+ ptrA szProto;
+ int iStatus;
+};
+
struct CMPlugin : public PLUGIN<CMPlugin>
{
CMPlugin();
+ CMOption<bool> bSyncStatusMsg, bSyncStatusState;
+
int Load() override;
-};
-class COptions
-{
enum
{
cssOnline = 0x00000001,
@@ -53,43 +63,21 @@ class COptions
return 0;
}
- struct PrevStatus
- {
- PrevStatus(const char *_proto, int _status) :
- szProto(mir_strdup(_proto)),
- iStatus(_status)
- {
- }
-
- ptrA szProto;
- int iStatus;
- };
-
OBJLIST<PrevStatus> m_aProtocol2Status;
- static int CompareStatuses(const PrevStatus *p1, const PrevStatus *p2)
- {
- return mir_strcmp(p1->szProto, p2->szProto);
- }
-
-public:
- COptions() :
- m_aProtocol2Status(3, CompareStatuses)
- {
- }
- bool IsProtocolExcluded(const char* pszProtocol)const
+ bool IsProtocolExcluded(const char *pszProtocol)const
{
uint32_t dwSettings = db_get_dw(NULL, pszProtocol, "ChangeSkypeStatus_Exclusions", 0);
- return ((dwSettings&cssAll) ? true : false);
+ return ((dwSettings & cssAll) ? true : false);
}
- bool IsProtocolStatusExcluded(const char* pszProtocol, int nStatus)const
+ bool IsProtocolStatusExcluded(const char *pszProtocol, int nStatus)const
{
uint32_t dwSettings = db_get_dw(NULL, pszProtocol, "ChangeSkypeStatus_Exclusions", 0);
- return ((dwSettings&Status2Flag(nStatus)) ? true : false);
+ return ((dwSettings & Status2Flag(nStatus)) ? true : false);
}
- void ExcludeProtocol(const char* pszProtocol, bool bExclude)
+ void ExcludeProtocol(const char *pszProtocol, bool bExclude)
{
uint32_t dwSettings = db_get_dw(NULL, pszProtocol, "ChangeSkypeStatus_Exclusions", 0);
if (bExclude)
@@ -100,7 +88,7 @@ public:
db_set_dw(NULL, pszProtocol, "ChangeSkypeStatus_Exclusions", dwSettings);
}
- void ExcludeProtocolStatus(const char* pszProtocol, int nStatus, bool bExclude)
+ void ExcludeProtocolStatus(const char *pszProtocol, int nStatus, bool bExclude)
{
uint32_t dwSettings = db_get_dw(NULL, pszProtocol, "ChangeSkypeStatus_Exclusions", 0);
if (bExclude)
@@ -111,29 +99,9 @@ public:
db_set_dw(NULL, pszProtocol, "ChangeSkypeStatus_Exclusions", dwSettings);
}
- bool GetSyncStatusMsgFlag() const
- {
- return g_plugin.getBool("SyncStatusMsg");
- }
-
- bool GetSyncStatusStateFlag() const
- {
- return g_plugin.getBool("SyncStatusState");
- }
-
- void SetSyncStatusMsgFlag(bool b)
+ bool GetPreviousStatus(const char *pszProtocol, int &nStatus)const
{
- g_plugin.setByte("SyncStatusMsg", b);
- }
-
- void SetSyncStatusStateFlag(bool b)
- {
- g_plugin.setByte("SyncStatusState", b);
- }
-
- bool GetPreviousStatus(const char* pszProtocol, int& nStatus)const
- {
- int i = m_aProtocol2Status.getIndex((PrevStatus*)&pszProtocol);
+ int i = m_aProtocol2Status.getIndex((PrevStatus *)&pszProtocol);
if (i != -1) {
nStatus = m_aProtocol2Status[i].iStatus;
return true;
@@ -142,9 +110,9 @@ public:
return false;
}
- void SetPreviousStatus(const char* pszProtocol, int nStatus)
+ void SetPreviousStatus(const char *pszProtocol, int nStatus)
{
- int i = m_aProtocol2Status.getIndex((PrevStatus*)&pszProtocol);
+ int i = m_aProtocol2Status.getIndex((PrevStatus *)&pszProtocol);
if (i != -1)
m_aProtocol2Status[i].iStatus = nStatus;
else
@@ -152,8 +120,6 @@ public:
}
};
-extern COptions g_Options;
-
/////////////////////////////////////////////////////////////////////////////////////////
struct CMirandaStatus2SkypeStatus