summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-10-27 10:29:01 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-10-27 10:29:01 +0000
commit9cc7d99f174805bc965f5bc6d0ba09e592515b80 (patch)
treef47e17ea2d751d193d3b6901cd3e5b09630f8c89 /protocols/VKontakte
parent908f1787312f52e30020163ba29d1326b76b4ca6 (diff)
VKontakte:
remove unneeded code add “Open broadcast” contacts menuitem when ListeningTo \<VK>Enabled is change, MusicSendMetod is also change some cleanup version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10877 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/res/broadcast.icobin0 -> 1150 bytes
-rw-r--r--protocols/VKontakte/res/resource.rc1
-rw-r--r--protocols/VKontakte/src/misc.cpp31
-rw-r--r--protocols/VKontakte/src/resource.h5
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp18
-rw-r--r--protocols/VKontakte/src/vk_proto.h7
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp30
-rw-r--r--protocols/VKontakte/vk_10.vcxproj1
-rw-r--r--protocols/VKontakte/vk_10.vcxproj.filters3
-rw-r--r--protocols/VKontakte/vk_12.vcxproj1
-rw-r--r--protocols/VKontakte/vk_12.vcxproj.filters3
12 files changed, 83 insertions, 19 deletions
diff --git a/protocols/VKontakte/res/broadcast.ico b/protocols/VKontakte/res/broadcast.ico
new file mode 100644
index 0000000000..07fb57cc6b
--- /dev/null
+++ b/protocols/VKontakte/res/broadcast.ico
Binary files differ
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc
index abad01a9a2..6368efe05c 100644
--- a/protocols/VKontakte/res/resource.rc
+++ b/protocols/VKontakte/res/resource.rc
@@ -34,6 +34,7 @@ IDI_ABUSE ICON "report.ico"
IDI_VISITPROFILE ICON "home.ico"
IDI_HISTORY ICON "history.ico"
IDI_KEYS ICON "key.ico"
+IDI_BROADCAST ICON "broadcast.ico"
#endif // () resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 98ab1cf2b1..e0b89acbff 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -189,7 +189,8 @@ static IconItem iconList[] =
{ LPGEN("Add to friend list icon"), "addfriend", IDI_FRIENDADD },
{ LPGEN("Delete from friend list icon"), "delfriend", IDI_FRIENDDEL },
{ LPGEN("Report abuse icon"), "abuse", IDI_ABUSE },
- { LPGEN("Ban user icon"), "ban", IDI_BAN}
+ { LPGEN("Ban user icon"), "ban", IDI_BAN},
+ { LPGEN("Broadcast icon"), "broadcast", IDI_BROADCAST}
};
void InitIcons()
@@ -594,4 +595,30 @@ char* CVkProto::GetStickerId(const char* Msg, int &stickerid)
}
stickerid = 0;
return NULL;
-} \ No newline at end of file
+}
+
+int CVkProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam)
+{
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
+ if (hContact != NULL)
+ return 0;
+
+ if (strcmp(cws->szModule, "ListeningTo"))
+ return 0;
+
+ CMStringA szListeningTo(m_szModuleName);
+ szListeningTo += "Enabled";
+ if (!strcmp(cws->szSetting, szListeningTo.GetBuffer())){
+ int iOldMusicSendMetod = getByte("OldMusicSendMetod", 3);
+
+ if (cws->value.bVal == 0)
+ setByte("OldMusicSendMetod", m_iMusicSendMetod);
+ else
+ db_unset(0, m_szModuleName, "OldMusicSendMetod");
+
+ m_iMusicSendMetod = cws->value.bVal == 0 ? 0 : iOldMusicSendMetod;
+ setByte("MusicSendMetod", m_iMusicSendMetod);
+ }
+
+ return 0;
+}
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index 6d5f834f72..9239bea5d2 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -16,6 +16,8 @@
#define IDI_ABUSE 114
#define IDI_VISITPROFILE 115
#define IDI_HISTORY 116
+#define IDI_ICON1 117
+#define IDI_BROADCAST 117
#define IDI_KEYS 203
#define IDC_LOGIN 1001
#define IDC_PASSWORD 1002
@@ -56,13 +58,12 @@
#define IDC_SEND_MUSIC_BROADCAST 1047
#define IDC_SEND_MUSIC_BROADCAST_AND_STATUS 1048
-
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 117
+#define _APS_NEXT_RESOURCE_VALUE 118
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1049
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 0c6d463a8e..0e7fd82216 100644
--- a/protocols/VKontakte/src/version.h
+++ b/protocols/VKontakte/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 25
+#define __BUILD_NUM 26
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 55c6d14e39..56b90c9dfa 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -60,7 +60,6 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
Clist_CreateGroup(NULL, m_defaultGroup);
db_set_resident(m_szModuleName, "Status");
- m_bOne = true;
m_bServerDelivery = getBool("ServerDelivery", true);
m_bHideChats = getBool("HideChats", true);
@@ -115,6 +114,7 @@ int CVkProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
// Other hooks
HookProtoEvent(ME_MSG_WINDOWEVENT, &CVkProto::OnProcessSrmmEvent);
HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CVkProto::OnDbEventRead);
+ HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &CVkProto::OnDbSettingChanged);
InitPopups();
InitMenus();
@@ -137,7 +137,8 @@ void CVkProto::InitMenus()
CreateProtoService(PS_BANUSER, &CVkProto::SvcBanUser);
CreateProtoService(PS_REPORTABUSE, &CVkProto::SvcReportAbuse);
CreateProtoService(PS_DESTROYKICKCHAT, &CVkProto::SvcDestroyKickChat);
-
+ CreateProtoService(PS_OPENBROADCAST, &CVkProto::SvcOpenBroadcast);
+
CLISTMENUITEM mi = { sizeof(mi) };
char szService[100];
@@ -208,19 +209,28 @@ void CVkProto::InitMenus()
mi.ptszName = LPGENT("Destroy room");
mi.pszService = szService;
g_hContactMenuItems[CMI_DESTROYKICKCHAT] = Menu_AddContactMenuItem(&mi);
+
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_OPENBROADCAST);
+ mi.position = -200001000 + CMI_OPENBROADCAST;
+ mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_BROADCAST));
+ mi.ptszName = LPGENT("Open broadcast");
+ mi.pszService = szService;
+ g_hContactMenuItems[CMI_OPENBROADCAST] = Menu_AddContactMenuItem(&mi);
}
int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
{
bool bisFriend = getByte(hContact, "Auth", -1)==0;
+ bool bisBroadcast = !(CMString(db_get_tsa(hContact, m_szModuleName, "AudioUrl")).IsEmpty());
Menu_ShowItem(g_hContactMenuItems[CMI_GETALLSERVERHISTORY], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_VISITPROFILE], !isChatRoom(hContact));
- Menu_ShowItem(g_hContactMenuItems[CMI_ADDASFRIEND], !bisFriend&&!isChatRoom(hContact));
+ Menu_ShowItem(g_hContactMenuItems[CMI_ADDASFRIEND], !bisFriend && !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_DELETEFRIEND], bisFriend);
Menu_ShowItem(g_hContactMenuItems[CMI_BANUSER], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_REPORTABUSE], !isChatRoom(hContact));
- Menu_ShowItem(g_hContactMenuItems[CMI_DESTROYKICKCHAT], isChatRoom(hContact)&&getBool(hContact, "off", false));
+ Menu_ShowItem(g_hContactMenuItems[CMI_DESTROYKICKCHAT], isChatRoom(hContact) && getBool(hContact, "off", false));
+ Menu_ShowItem(g_hContactMenuItems[CMI_OPENBROADCAST], !isChatRoom(hContact) && bisBroadcast);
return 0;
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 5a64b94fb3..786bd082b6 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PS_BANUSER "/BanUser"
#define PS_REPORTABUSE "/ReportAbuse"
#define PS_DESTROYKICKCHAT "/DestroyKickChat"
+#define PS_OPENBROADCAST "/OpenBroadcast"
#define MAXHISTORYMIDSPERONE 200
#define MAX_RETRIES 10
@@ -239,6 +240,7 @@ struct CVkProto : public PROTO<CVkProto>
INT_PTR __cdecl SvcReportAbuse(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcGetAllServerHistory(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcDestroyKickChat(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcOpenBroadcast(WPARAM hContact, LPARAM);
void InitMenus();
void UnInitMenus();
int __cdecl OnPreBuildContactMenu(WPARAM hContact, LPARAM);
@@ -252,7 +254,7 @@ struct CVkProto : public PROTO<CVkProto>
int __cdecl OnProcessSrmmEvent(WPARAM, LPARAM);
int __cdecl OnDbEventRead(WPARAM, LPARAM);
-
+ int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
//==== Search ========================================================================
void __cdecl SearchBasicThread(void* id);
@@ -336,7 +338,7 @@ private:
mir_cs m_csRequestsQueue;
HANDLE m_evRequestsQueue;
HANDLE m_hWorkerThread;
- bool m_bTerminated, m_bServerDelivery, m_bOne;
+ bool m_bTerminated, m_bServerDelivery;
CMStringA m_prevUrl;
enum CLMenuIndexes {
@@ -347,6 +349,7 @@ private:
CMI_BANUSER,
CMI_REPORTABUSE,
CMI_DESTROYKICKCHAT,
+ CMI_OPENBROADCAST,
CMI_COUNT
};
enum ProtoMenuIndexes {
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index d72fcecc1a..191be83f70 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -105,7 +105,8 @@ void CVkProto::SetServerStatus(int iNewStatus)
if (iNewStatus == ID_STATUS_OFFLINE) {
m_iStatus = ID_STATUS_OFFLINE;
- if (!ListeningToMsg.IsEmpty()) RetrieveStatusMsg(oldStatusMsg);
+ if (!ListeningToMsg.IsEmpty())
+ RetrieveStatusMsg(oldStatusMsg);
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/account.setOffline.json", true, &CVkProto::OnReceiveSmth)
<< VER_API);
}
@@ -116,7 +117,8 @@ void CVkProto::SetServerStatus(int iNewStatus)
}
else {
m_iStatus = ID_STATUS_INVISIBLE;
- if (!ListeningToMsg.IsEmpty()) RetrieveStatusMsg(oldStatusMsg);
+ if (!ListeningToMsg.IsEmpty())
+ RetrieveStatusMsg(oldStatusMsg);
}
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus);
@@ -339,17 +341,19 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
CMString tszOldStatus(db_get_tsa(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg"));
if (tszValue != tszOldStatus){
db_set_ts(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg", tszValue.GetBuffer());
- if ((json_get(pItem, "status_audio") != NULL) || (tszValue.GetBuffer()[0] == TCHAR(9835)))
+ db_unset(hContact, m_szModuleName, "AudioUrl");
+ JSONNODE* pAudio = json_get(pItem, "status_audio");
+ if (pAudio != NULL) {
db_set_ts(hContact, m_szModuleName, "ListeningTo", tszValue.GetBuffer());
+ tszValue = json_as_string(json_get(pAudio, "url"));
+ db_set_ts(hContact, m_szModuleName, "AudioUrl", tszValue.GetBuffer());
+ }
+ else if ((tszValue.GetBuffer()[0] == TCHAR(9835)) && (tszValue.GetLength() > 2))
+ db_set_ts(hContact, m_szModuleName, "ListeningTo", &(tszValue.GetBuffer())[2]);
else
db_unset(hContact, m_szModuleName, "ListeningTo");
}
- if ((hContact == NULL) && m_bOne){
- setTString("OldStatusMsg", db_get_tsa(0, m_szModuleName, "StatusMsg"));
- m_bOne = false;
- }
-
tszValue = json_as_string(json_get(pItem, "about"));
if (!tszValue.IsEmpty())
@@ -1097,6 +1101,16 @@ INT_PTR __cdecl CVkProto::SvcReportAbuse(WPARAM hContact, LPARAM)
return 0;
}
+INT_PTR __cdecl CVkProto::SvcOpenBroadcast(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcOpenBroadcast");
+ CMString tszAudio(db_get_tsa(hContact, m_szModuleName, "AudioUrl"));
+
+ if (!tszAudio.IsEmpty())
+ CallService(MS_UTILS_OPENURL, (WPARAM)OUF_TCHAR, (LPARAM)tszAudio.GetBuffer());
+
+ return 0;
+}
INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM)
{
diff --git a/protocols/VKontakte/vk_10.vcxproj b/protocols/VKontakte/vk_10.vcxproj
index 3694620959..263574500e 100644
--- a/protocols/VKontakte/vk_10.vcxproj
+++ b/protocols/VKontakte/vk_10.vcxproj
@@ -204,6 +204,7 @@
<ItemGroup>
<None Include="res\add.ico" />
<None Include="res\ban.ico" />
+ <None Include="res\broadcast.ico" />
<None Include="res\delete.ico" />
<None Include="res\history.ico" />
<None Include="res\home.ico" />
diff --git a/protocols/VKontakte/vk_10.vcxproj.filters b/protocols/VKontakte/vk_10.vcxproj.filters
index 61d01e9ddc..46599a9c11 100644
--- a/protocols/VKontakte/vk_10.vcxproj.filters
+++ b/protocols/VKontakte/vk_10.vcxproj.filters
@@ -105,5 +105,8 @@
<None Include="res\report.ico">
<Filter>Resource Files</Filter>
</None>
+ <None Include="res\broadcast.ico">
+ <Filter>Resource Files</Filter>
+ </None>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/VKontakte/vk_12.vcxproj b/protocols/VKontakte/vk_12.vcxproj
index b272a53f2d..d9eea221e1 100644
--- a/protocols/VKontakte/vk_12.vcxproj
+++ b/protocols/VKontakte/vk_12.vcxproj
@@ -207,6 +207,7 @@
<ItemGroup>
<Image Include="res\add.ico" />
<Image Include="res\ban.ico" />
+ <Image Include="res\broadcast.ico" />
<Image Include="res\delete.ico" />
<Image Include="res\history.ico" />
<Image Include="res\home.ico" />
diff --git a/protocols/VKontakte/vk_12.vcxproj.filters b/protocols/VKontakte/vk_12.vcxproj.filters
index f48849cd87..7629914fa3 100644
--- a/protocols/VKontakte/vk_12.vcxproj.filters
+++ b/protocols/VKontakte/vk_12.vcxproj.filters
@@ -105,5 +105,8 @@
<Image Include="res\history.ico">
<Filter>Resource Files</Filter>
</Image>
+ <Image Include="res\broadcast.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
</ItemGroup>
</Project> \ No newline at end of file