diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2012-10-03 18:30:39 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2012-10-03 18:30:39 +0000 |
commit | fdae978639989c9988f16385d4cdfb32a0467ef0 (patch) | |
tree | 2eed678ad08751613ddf34a4209e934f78a6115e /protocols | |
parent | 8cb2a99e08a3f8fadc3b39f00228efa7d2b20050 (diff) |
- added skype_menus.cpp, skype_services.cpp
- some minor changes
git-svn-id: http://svn.miranda-ng.org/main/trunk@1773 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Skype/Skype.vcxproj | 2 | ||||
-rw-r--r-- | protocols/Skype/Skype.vcxproj.filters | 6 | ||||
-rw-r--r-- | protocols/Skype/src/skype.cpp | 7 | ||||
-rw-r--r-- | protocols/Skype/src/skype.h | 8 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 52 | ||||
-rw-r--r-- | protocols/Skype/src/skype_dialogs.cpp | 81 | ||||
-rw-r--r-- | protocols/Skype/src/skype_icons.cpp | 48 | ||||
-rw-r--r-- | protocols/Skype/src/skype_menus.cpp | 71 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 61 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 30 | ||||
-rw-r--r-- | protocols/Skype/src/skype_services.cpp | 9 |
11 files changed, 231 insertions, 144 deletions
diff --git a/protocols/Skype/Skype.vcxproj b/protocols/Skype/Skype.vcxproj index 35cc7da653..840bdab114 100644 --- a/protocols/Skype/Skype.vcxproj +++ b/protocols/Skype/Skype.vcxproj @@ -109,8 +109,10 @@ <ClCompile Include="src\skype_dialogs.cpp" />
<ClCompile Include="src\skype_events.cpp" />
<ClCompile Include="src\skype_icons.cpp" />
+ <ClCompile Include="src\skype_menus.cpp" />
<ClCompile Include="src\skype_netlib.cpp" />
<ClCompile Include="src\skype_proto.cpp" />
+ <ClCompile Include="src\skype_services.cpp" />
<ClCompile Include="src\skype_settings.cpp" />
<ClCompile Include="src\skype_subclassing.cpp" />
<ClCompile Include="src\skype_utils.cpp" />
diff --git a/protocols/Skype/Skype.vcxproj.filters b/protocols/Skype/Skype.vcxproj.filters index f4224aaf7b..9146250037 100644 --- a/protocols/Skype/Skype.vcxproj.filters +++ b/protocols/Skype/Skype.vcxproj.filters @@ -42,6 +42,12 @@ <ClCompile Include="src\skype_netlib.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\skype_services.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skype_menus.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\resource.h">
diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index db983a1b68..a3e5823c7b 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -94,7 +94,6 @@ void StartSkypeRuntime() {
// loading skype runtime
// shitcode
- int port = 8963;
wchar_t* bsp;
STARTUPINFO cif;
PROCESS_INFORMATION pi;
@@ -155,13 +154,17 @@ extern "C" int __declspec(dllexport) Load(void) pd.fnUninit = (pfnUninitProto)SkypeProtoUninit;
CallService(MS_PROTO_REGISTERMODULE, 0, reinterpret_cast<LPARAM>(&pd));
- IconsLoad();
+ CSkypeProto::InitIcons();
+ CSkypeProto::InitMenus();
return 0;
}
extern "C" int __declspec(dllexport) Unload(void)
{
+ CSkypeProto::UninitMenus();
+ CSkypeProto::UninitIcons();
+
g_skype->stop();
delete g_skype;
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index 2382950b22..fe28a32f84 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -43,9 +43,7 @@ #include "resource.h"
#include "version.h"
-extern HINSTANCE g_hInstance;
-
-void IconsLoad();
+#include "skype_subclassing.h"
#define MODULE "Skype"
#define SKYPE_SETTINGS_NAME "Name"
@@ -53,7 +51,7 @@ void IconsLoad(); #define SKYPE_SETTINGS_LOGIN "SkypeLogin"
#define SKYPE_SETTINGS_PASSWORD "Password"
-#include "skype_subclassing.h"
-
extern CSkype* g_skype;
+extern HINSTANCE g_hInstance;
+
static const char* g_keyFileName = "..\\..\\..\\SkypeKit\\keypair.crt";
\ No newline at end of file diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 674c71adc6..46169ef871 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -10,18 +10,22 @@ void CSkypeProto::OnContactChanged(CContact* contact, int prop) contact->GetPropSkypename(data);
wchar_t* skypeName = ::mir_a2u((const char*)data);
- contact->GetPropDisplayname(data);
- wchar_t* displayName = ::mir_a2u((const char*)data);
-
- HANDLE hContact = this->AddContactBySkypeName(skypeName, displayName, 0);
-
- CContact::AVAILABILITY availability;
- contact->GetPropAvailability(availability);
- this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(availability));
+ HANDLE hContact = this->GetContactBySkypeName(skypeName);
+ if (hContact)
+ {
+ CContact::AVAILABILITY availability;
+ contact->GetPropAvailability(availability);
+ this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(availability));
+
+ if (availability == CContact::PENDINGAUTH)
+ this->SetSettingWord(hContact, "Auth", 1);
+ else
+ DBDeleteContactSetting(hContact, this->m_szModuleName, "Auth");
+ }
}
}
-bool CSkypeProto::IsSkypeContact(HANDLE hContact)
+bool CSkypeProto::IsProtoContact(HANDLE hContact)
{
return (::CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName));
}
@@ -31,7 +35,7 @@ HANDLE CSkypeProto::GetContactBySkypeName(wchar_t* skypeName) HANDLE hContact = (HANDLE)::CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
while (hContact)
{
- if (this->IsSkypeContact(hContact))
+ if (this->IsProtoContact(hContact))
{
if (::wcscmp(skypeName, this->GetSettingString(hContact, "SkypeName", L"")) == 0)
return hContact;
@@ -52,8 +56,8 @@ HANDLE CSkypeProto::AddContactBySkypeName(wchar_t* skypeName, wchar_t* displayNa ::CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName);
this->SetSettingString(hContact, "SkypeName", skypeName);
- this->SetSettingString(hContact, "DisplayName", displayName);
- ::DBWriteContactSettingWString(hContact, "CList", "MyHandle", displayName);
+ this->SetSettingString(hContact, "Nick", displayName);
+ //::DBWriteContactSettingWString(hContact, "CList", "MyHandle", displayName);
if (flags & PALF_TEMPORARY)
{
@@ -131,7 +135,6 @@ void __cdecl CSkypeProto::LoadContactList(void*) for (unsigned int i = 0; i < this->contactGroup->ContactList.size(); i++)
{
CContact::Ref contact = this->contactGroup->ContactList[i];
-
contact->SetOnContactChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
SEString data;
@@ -140,25 +143,30 @@ void __cdecl CSkypeProto::LoadContactList(void*) wchar_t* skypeName = ::mir_a2u((const char*)data);
contact->GetPropDisplayname(data);
- wchar_t* displayName = ::mir_a2u((const char*)data);
+ wchar_t* displayName = :: mir_utf8decodeW((const char*)data);
HANDLE hContact = this->AddContactBySkypeName(skypeName, displayName, 0);
-
+
CContact::AVAILABILITY availability;
contact->GetPropAvailability(availability);
this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(availability));
+
+ if (availability == CContact::PENDINGAUTH)
+ this->SetSettingWord(hContact, "Auth", 1);
+ else
+ DBDeleteContactSetting(hContact, this->m_szModuleName, "Auth");
}
}
-void CSkypeProto::SetAllContactStatuses(int status)
+void CSkypeProto::SetAllContactStatus(int status)
{
- for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- hContact;
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0))
+ HANDLE hContact = (HANDLE)::CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (hContact)
{
- if (this->GetSettingWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_OFFLINE) == status)
- continue;
+ if (this->IsProtoContact(hContact))
+ if ( !this->GetSettingWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_OFFLINE) == status)
+ this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, status);
- this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, status);
+ hContact = (HANDLE)::CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
}
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index f8563c4922..ca9a3ce63f 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -7,37 +7,25 @@ INT_PTR CALLBACK CSkypeProto::SkypeAccountProc(HWND hwnd, UINT message, WPARAM w switch (message)
{
case WM_INITDIALOG:
+ {
TranslateDialogDefault(hwnd);
proto = reinterpret_cast<CSkypeProto*>(lparam);
SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
- DBVARIANT dbv;
- if ( !DBGetContactSettingWString(0, proto->ModuleName(), SKYPE_SETTINGS_LOGIN, &dbv))
- {
- SetDlgItemText(hwnd, IDC_SL, dbv.ptszVal);
- DBFreeVariant(&dbv);
- }
-
- if ( !DBGetContactSettingWString(0, proto->ModuleName(), SKYPE_SETTINGS_PASSWORD, &dbv))
- {
- CallService(
- MS_DB_CRYPT_DECODESTRING,
- wcslen(dbv.ptszVal) + 1,
- reinterpret_cast<LPARAM>(dbv.ptszVal));
- SetDlgItemText(hwnd, IDC_PW, dbv.ptszVal);
- DBFreeVariant(&dbv);
- }
+ SetDlgItemText(hwnd, IDC_SL, proto->GetSettingString(SKYPE_SETTINGS_LOGIN, L""));
+ SetDlgItemText(hwnd, IDC_SL, proto->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, L""));
- if ( !proto->IsOffline())
+ if ( proto->m_iStatus != ID_STATUS_OFFLINE)
{
SendMessage(GetDlgItem(hwnd, IDC_SL), EM_SETREADONLY, 1, 0);
SendMessage(GetDlgItem(hwnd, IDC_PW), EM_SETREADONLY, 1, 0);
}
-
- return TRUE;
+ }
+ return TRUE;
case WM_COMMAND:
+ {
if (HIWORD(wparam) == EN_CHANGE && reinterpret_cast<HWND>(lparam) == GetFocus())
{
switch(LOWORD(wparam))
@@ -47,24 +35,26 @@ INT_PTR CALLBACK CSkypeProto::SkypeAccountProc(HWND hwnd, UINT message, WPARAM w SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
}
- break;
+ }
+ break;
case WM_NOTIFY:
+ {
if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY)
{
- proto = reinterpret_cast<CSkypeProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
- TCHAR str[128];
+ TCHAR data[128];
+ proto = reinterpret_cast<CSkypeProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
- GetDlgItemText(hwnd, IDC_SL, str, sizeof(str));
- DBWriteContactSettingWString(0, proto->ModuleName(), SKYPE_SETTINGS_LOGIN, str);
+ GetDlgItemText(hwnd, IDC_SL, data, sizeof(data));
+ proto->SetSettingString(SKYPE_SETTINGS_LOGIN, data);
- GetDlgItemText(hwnd, IDC_PW, str, sizeof(str));
- CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), reinterpret_cast<LPARAM>(str));
- DBWriteContactSettingWString(0, proto->ModuleName(), SKYPE_SETTINGS_PASSWORD, str);
+ GetDlgItemText(hwnd, IDC_PW, data, sizeof(data));
+ proto->SetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, data);
return TRUE;
}
- break;
+ }
+ break;
}
@@ -84,24 +74,10 @@ INT_PTR CALLBACK CSkypeProto::SkypeOptionsProc(HWND hwnd, UINT message, WPARAM w proto = reinterpret_cast<CSkypeProto*>(lparam);
SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
- DBVARIANT dbv;
- if ( !DBGetContactSettingString(0, proto->ModuleName(), SKYPE_SETTINGS_LOGIN, &dbv))
- {
- SetDlgItemText(hwnd, IDC_SL, dbv.ptszVal);
- DBFreeVariant(&dbv);
- }
-
- if ( !DBGetContactSettingString(0, proto->ModuleName(), SKYPE_SETTINGS_PASSWORD, &dbv))
- {
- CallService(
- MS_DB_CRYPT_DECODESTRING,
- wcslen(dbv.ptszVal) + 1,
- reinterpret_cast<LPARAM>(dbv.ptszVal));
- SetDlgItemText(hwnd, IDC_PW, dbv.ptszVal);
- DBFreeVariant(&dbv);
- }
+ SetDlgItemText(hwnd, IDC_SL, proto->GetSettingString(SKYPE_SETTINGS_LOGIN, L""));
+ SetDlgItemText(hwnd, IDC_PW, proto->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, L""));
- if ( !proto->IsOffline())
+ if (proto->m_iStatus != ID_STATUS_OFFLINE)
{
SendMessage(GetDlgItem(hwnd, IDC_SL), EM_SETREADONLY, 1, 0);
SendMessage(GetDlgItem(hwnd, IDC_PW), EM_SETREADONLY, 1, 0);
@@ -120,20 +96,21 @@ INT_PTR CALLBACK CSkypeProto::SkypeOptionsProc(HWND hwnd, UINT message, WPARAM w SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
}
- break;
+ }
+ break;
case WM_NOTIFY:
+ {
if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY)
{
+ wchar_t data[128];
proto = reinterpret_cast<CSkypeProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
- TCHAR str[128];
- GetDlgItemText(hwnd, IDC_SL, str, sizeof(str));
- DBWriteContactSettingTString(0, proto->ModuleName(), SKYPE_SETTINGS_LOGIN, str);
+ GetDlgItemText(hwnd, IDC_SL, data, sizeof(data));
+ proto->SetSettingString(SKYPE_SETTINGS_LOGIN, data);
- GetDlgItemText(hwnd, IDC_PW, str, sizeof(str));
- CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), reinterpret_cast<LPARAM>(str));
- DBWriteContactSettingTString(0, proto->ModuleName(), SKYPE_SETTINGS_PASSWORD, str);
+ GetDlgItemText(hwnd, IDC_PW, data, sizeof(data));
+ proto->SetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, data);
return TRUE;
}
diff --git a/protocols/Skype/src/skype_icons.cpp b/protocols/Skype/src/skype_icons.cpp index db213b8197..bb8c727cb5 100644 --- a/protocols/Skype/src/skype_icons.cpp +++ b/protocols/Skype/src/skype_icons.cpp @@ -1,41 +1,47 @@ #include "skype_proto.h"
+// todo: need to move in CSkypeProto struct
struct _tag_iconList
{
- TCHAR* szDescr;
- char* szName;
- int defIconID;
- HANDLE hIconLibItem;
-}
-
-static iconList[] =
+ wchar_t* Description;
+ char* Name;
+ int IconId;
+ HANDLE Handle;
+} static iconList[] =
{
- {LPGENT("Protocol icon"), "main", IDI_ICON},
+ { LPGENT("Protocol icon"), "main", IDI_ICON },
};
-void IconsLoad()
+void CSkypeProto::InitIcons()
{
- TCHAR szFile[MAX_PATH];
- char szSettingName[100];
- TCHAR szSectionName[100];
- SKINICONDESC sid = {0};
- unsigned i;
+ wchar_t szFile[MAX_PATH];
+ ::GetModuleFileName(g_hInstance, szFile, MAX_PATH);
- GetModuleFileName(g_hInstance, szFile, MAX_PATH);
+ char szSettingName[100];
+ wchar_t szSectionName[100];
+ SKINICONDESC sid = {0};
sid.cbSize = sizeof(SKINICONDESC);
sid.flags = SIDF_ALL_TCHAR;
sid.ptszDefaultFile = szFile;
sid.pszName = szSettingName;
sid.ptszSection = szSectionName;
- mir_sntprintf(szSectionName, SIZEOF(szSectionName), _T("%s/%s"), LPGENT("Protocols"), LPGENT(MODULE));
- for (i = 0; i < SIZEOF(iconList); i++)
+ ::mir_sntprintf(szSectionName, SIZEOF(szSectionName), _T("%s/%s"), LPGENT("Protocols"), LPGENT(MODULE));
+ for (int i = 0; i < SIZEOF(iconList); i++)
{
- mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, iconList[i].szName);
+ ::mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, iconList[i].Name);
- sid.ptszDescription = iconList[i].szDescr;
- sid.iDefaultIndex = -iconList[i].defIconID;
- iconList[i].hIconLibItem = Skin_AddIcon(&sid);
+ sid.ptszDescription = iconList[i].Description;
+ sid.iDefaultIndex = -iconList[i].IconId;
+ iconList[i].Handle = ::Skin_AddIcon(&sid);
}
+}
+
+void CSkypeProto::UninitIcons()
+{
+ for (int i = 0; i < SIZEOF(iconList); i++)
+ {
+ ::Skin_RemoveIcon(iconList[i].Name);
+ }
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp new file mode 100644 index 0000000000..dd53e6f41d --- /dev/null +++ b/protocols/Skype/src/skype_menus.cpp @@ -0,0 +1,71 @@ +#include "skype_proto.h"
+
+HANDLE CSkypeProto::hPrebuildMenuHook;
+
+int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
+{
+ HANDLE hContact = (HANDLE)wParam;
+
+ if (hContact == NULL)
+ return 0;
+
+ return 0;
+}
+
+CSkypeProto* CSkypeProto::GetInstanceByHContact(HANDLE hContact)
+{
+ char* proto = (char*)::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ if (proto == NULL)
+ return NULL;
+
+ for (int i = 0; i < g_Instances.getCount(); i++)
+ if (!strcmp(proto, g_Instances[i]->m_szModuleName))
+ return g_Instances[i];
+
+ return NULL;
+}
+
+int CSkypeProto::PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
+{
+ /*sttEnableMenuItem( g_hMenuRequestAuth, FALSE );
+ sttEnableMenuItem( g_hMenuGrantAuth, FALSE );
+ sttEnableMenuItem( g_hMenuRevokeAuth, FALSE );
+ sttEnableMenuItem( g_hMenuCommands, FALSE );
+ sttEnableMenuItem( g_hMenuSendNote, FALSE );
+ sttEnableMenuItem( g_hMenuConvert, FALSE );
+ sttEnableMenuItem( g_hMenuRosterAdd, FALSE );
+ sttEnableMenuItem( g_hMenuLogin, FALSE );
+ sttEnableMenuItem( g_hMenuRefresh, FALSE );
+ sttEnableMenuItem( g_hMenuAddBookmark, FALSE );
+ sttEnableMenuItem( g_hMenuResourcesRoot, FALSE );
+ sttEnableMenuItem( g_hMenuDirectPresence[0], FALSE );*/
+
+ CSkypeProto* ppro = CSkypeProto::GetInstanceByHContact((HANDLE)wParam);
+ return (ppro) ? ppro->OnPrebuildContactMenu(wParam, lParam) : 0;
+}
+
+void CSkypeProto::InitMenus()
+{
+ CSkypeProto::hPrebuildMenuHook = ::HookEvent(ME_CLIST_PREBUILDCONTACTMENU, CSkypeProto::PrebuildContactMenu);
+
+ //List_InsertPtr( &arServices, CreateServiceFunction( "Jabber/MenuChoose", JabberMenuChooseService ));
+
+ /*TMenuParam mnu = {0};
+ mnu.cbSize = sizeof(mnu);
+ mnu.name = "JabberAccountChooser";
+ mnu.ExecService = "Jabber/MenuChoose";
+ hChooserMenu = (HANDLE)CallService( MO_CREATENEWMENUOBJECT, 0, (LPARAM)&mnu );
+
+ TMO_MenuItem tmi = { 0 };
+ tmi.cbSize = sizeof( tmi );
+ tmi.flags = CMIF_ICONFROMICOLIB;
+ tmi.pszName = "Cancel";
+ tmi.position = 9999999;
+ tmi.hIcolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE);
+ CallService( MO_ADDNEWMENUITEM, (WPARAM)hChooserMenu, ( LPARAM )&tmi );*/
+}
+
+void CSkypeProto::UninitMenus()
+{
+ ::UnhookEvent(CSkypeProto::hPrebuildMenuHook);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index c21880caf4..cbc9b6fdf0 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -11,13 +11,10 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) //this->m_szProtoName[0] = toupper(m_szProtoName[0]);
this->signin_lock = CreateMutex(0, false, 0);
- this->SetAllContactStatuses(ID_STATUS_OFFLINE);
+ this->SetAllContactStatus(ID_STATUS_OFFLINE);
this->InitNetLib();
- //->SetOnChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
- //.SetOnChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
-
this->CreateService(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
}
@@ -34,32 +31,31 @@ CSkypeProto::~CSkypeProto() HANDLE __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
- //if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
- // return 0;
- //
- //return this->AddContactBySkypeName(psr->id, psr->nick, flags);
- return 0;
+ if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
+ return 0;
+
+ return this->AddContactBySkypeName(psr->id, psr->nick, flags);
}
HANDLE __cdecl CSkypeProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent)
{
- //DBEVENTINFO dbei = {0};
- //dbei.cbSize = sizeof(dbei);
-
- //if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) != -1)
- //{
- // dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- // if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0 &&
- // !strcmp(dbei.szModule, m_szModuleName) &&
- // (dbei.eventType == EVENTTYPE_AUTHREQUEST || dbei.eventType == EVENTTYPE_CONTACTS))
- // {
- // char *nick = (char*)(dbei.pBlob + sizeof(DWORD) * 2);
- // char *firstName = nick + strlen(nick) + 1;
- // char *lastName = firstName + strlen(firstName) + 1;
- // char *skypeName = lastName + strlen(lastName) + 1;
- // return AddContactBySkypeName(::mir_a2u(skypeName), ::mir_a2u(nick), 0);
- // }
- //}
+ DBEVENTINFO dbei = {0};
+ dbei.cbSize = sizeof(dbei);
+
+ if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) != -1)
+ {
+ dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
+ if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0 &&
+ !strcmp(dbei.szModule, m_szModuleName) &&
+ (dbei.eventType == EVENTTYPE_AUTHREQUEST || dbei.eventType == EVENTTYPE_CONTACTS))
+ {
+ char *nick = (char*)(dbei.pBlob + sizeof(DWORD) * 2);
+ char *firstName = nick + strlen(nick) + 1;
+ char *lastName = firstName + strlen(firstName) + 1;
+ char *skypeName = lastName + strlen(lastName) + 1;
+ return AddContactBySkypeName(::mir_a2u(skypeName), ::mir_a2u(nick), 0);
+ }
+ }
return 0;
}
@@ -141,7 +137,7 @@ int CSkypeProto::SetStatus(int new_status) this->account->Logout(true);
this->account->BlockWhileLoggingOut();
this->account->SetAvailability(CContact::OFFLINE);
- this->SetAllContactStatuses(ID_STATUS_OFFLINE);
+ this->SetAllContactStatus(ID_STATUS_OFFLINE);
}
else
{
@@ -190,17 +186,6 @@ int __cdecl CSkypeProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPA return 1;
}
-
-char* CSkypeProto::ModuleName()
-{
- return this->m_szModuleName;
-}
-
-bool CSkypeProto::IsOffline()
-{
- return this->m_iStatus == ID_STATUS_OFFLINE;
-}
-
void __cdecl CSkypeProto::SignIn(void*)
{
WaitForSingleObject(&this->signin_lock, INFINITE);
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index d9f2a4b634..a6dbec8df5 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -4,6 +4,8 @@ struct CSkypeProto;
+extern LIST<CSkypeProto> g_Instances;
+
typedef void (__cdecl CSkypeProto::* SkypeThreadFunc) (void*);
typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFunc)(WPARAM, LPARAM);
typedef int (__cdecl CSkypeProto::* SkypeEventFunc)(WPARAM, LPARAM);
@@ -69,8 +71,20 @@ public: int __cdecl OnOptionsInit(WPARAM, LPARAM);
int __cdecl OnAccountManagerInit(WPARAM wParam, LPARAM lParam);
- char* ModuleName();
- bool IsOffline();
+ // services
+ static void InitServiceList();
+ static void UninitServiceList();
+
+ // icons
+ static void InitIcons();
+ static void UninitIcons();
+
+ // menus
+ static void InitMenus();
+ static void UninitMenus();
+
+ static CSkypeProto* GetInstanceByHContact(HANDLE hContact);
+ static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
protected:
CAccount::Ref account;
@@ -87,12 +101,12 @@ protected: // contacts
void OnContactChanged(CContact* contact, int prop);
- bool IsSkypeContact(HANDLE hContact);
+ bool IsProtoContact(HANDLE hContact);
HANDLE AddContactBySkypeName(wchar_t* skypeName, wchar_t* displayName, DWORD flags);
HANDLE GetContactBySkypeName(wchar_t* skypeName);
int SkypeToMirandaStatus(CContact::AVAILABILITY availability);
CContact::AVAILABILITY MirandaToSkypeStatus(int status);
- void SetAllContactStatuses(int status);
+ void SetAllContactStatus(int status);
// utils
void CreateService(const char* szService, SkypeServiceFunc serviceProc);
@@ -113,6 +127,14 @@ protected: void UninitNetLib();
void Log(const char* fmt, ...);
+ // services
+ //static LIST<HANDLE> serviceList;
+
+ // menu
+ static HANDLE hPrebuildMenuHook;
+
+ int OnPrebuildContactMenu(WPARAM wParam, LPARAM);
+
// database settings
BYTE GetSettingByte(const char *setting, BYTE errorValue = 0);
BYTE GetSettingByte(HANDLE hContact, const char *setting, BYTE errorValue = 0);
diff --git a/protocols/Skype/src/skype_services.cpp b/protocols/Skype/src/skype_services.cpp new file mode 100644 index 0000000000..a575f590fd --- /dev/null +++ b/protocols/Skype/src/skype_services.cpp @@ -0,0 +1,9 @@ +#include "skype_proto.h"
+
+void CSkypeProto::InitServiceList()
+{
+}
+
+void CSkypeProto::UninitServiceList()
+{
+}
|