summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-10-29 21:30:23 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-10-29 21:30:23 +0300
commitb54e9f486d521c314a9eb53dab435f14b4ca7504 (patch)
tree8b589d579a96a0c8c7a4027905bdaa32eb9b5a52 /protocols/SkypeWeb/src
parentf4f91f87f7a95733351f743180089d51b37f66b9 (diff)
SkypeWeb:
- fixes #2491 (correct visualization of Skype invitations); - massive code cleaning; - version bump
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp61
-rw-r--r--protocols/SkypeWeb/src/skype_db.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp8
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h2
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp6
-rw-r--r--protocols/SkypeWeb/src/version.h2
9 files changed, 48 insertions, 43 deletions
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 718c6b55df..0a86517a7a 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -254,7 +254,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
CMStringW szTopic(node["threadtopic"].as_mstring());
- time_t timestamp = IsoToUnixTime(node["composetime"].as_string().c_str());
+ time_t timestamp = IsoToUnixTime(node["composetime"].as_string());
std::string strContent = node["content"].as_string();
int nEmoteOffset = node["skypeemoteoffset"].as_int();
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index c8b56066fd..0e8c4d34a8 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -28,7 +28,7 @@ void CSkypeProto::SetContactStatus(MCONTACT hContact, WORD status)
if (oldStatus != status) {
setWord(hContact, "Status", status);
if (status == ID_STATUS_OFFLINE)
- db_unset(hContact, m_szModuleName, "MirVer");
+ delSetting(hContact, "MirVer");
}
}
@@ -69,24 +69,24 @@ MCONTACT CSkypeProto::FindContact(const char *skypename)
MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary)
{
MCONTACT hContact = FindContact(skypename);
+ if (hContact)
+ return hContact;
- if (!hContact) {
- hContact = db_add_contact();
- Proto_AddToContact(hContact, m_szModuleName);
+ hContact = db_add_contact();
+ Proto_AddToContact(hContact, m_szModuleName);
- setString(hContact, SKYPE_SETTINGS_ID, skypename);
+ setString(hContact, SKYPE_SETTINGS_ID, skypename);
- if (m_opts.wstrCListGroup) {
- Clist_GroupCreate(0, m_opts.wstrCListGroup);
- Clist_SetGroup(hContact, m_opts.wstrCListGroup);
- }
+ if (m_opts.wstrCListGroup) {
+ Clist_GroupCreate(0, m_opts.wstrCListGroup);
+ Clist_SetGroup(hContact, m_opts.wstrCListGroup);
+ }
- setByte(hContact, "Auth", 1);
- setByte(hContact, "Grant", 1);
+ setByte(hContact, "Auth", 1);
+ setByte(hContact, "Grant", 1);
- if (isTemporary)
- Contact_RemoveFromList(hContact);
- }
+ if (isTemporary)
+ Contact_RemoveFromList(hContact);
return hContact;
}
@@ -101,26 +101,31 @@ void CSkypeProto::LoadContactsAuth(NETLIBHTTPREQUEST *response, AsyncHttpRequest
std::string skypename = item["mri"].as_string().erase(0, 2);
std::string reason = item["greeting"].as_string();
- time_t eventTime = IsoToUnixTime(item["invites"][json_index_t(0)].as_string().c_str());
+ time_t eventTime = 0;
+ for (auto &it : item["invites"])
+ eventTime = IsoToUnixTime(it["time"].as_string());
MCONTACT hContact = AddContact(skypename.c_str());
- if (hContact) {
- time_t lastEventTime = db_get_dw(hContact, m_szModuleName, "LastAuthRequestTime", 0);
+ time_t lastEventTime = getDword(hContact, "LastAuthRequestTime");
+ if (lastEventTime && lastEventTime >= eventTime)
+ continue;
- if (lastEventTime < eventTime) {
- db_set_dw(hContact, m_szModuleName, "LastAuthRequestTime", eventTime);
- delSetting(hContact, "Auth");
+ std::string displayName = item["displayname"].as_string();
+ if (displayName.empty())
+ displayName = skypename;
+ setUString(hContact, "Nick", displayName.c_str());
- DB::AUTH_BLOB blob(hContact, nullptr, nullptr, nullptr, skypename.c_str(), reason.c_str());
+ setDword(hContact, "LastAuthRequestTime", eventTime);
+ delSetting(hContact, "Auth");
- PROTORECVEVENT pre = { 0 };
- pre.timestamp = time(0);
- pre.lParam = blob.size();
- pre.szMessage = blob;
+ DB::AUTH_BLOB blob(hContact, displayName.c_str(), nullptr, nullptr, skypename.c_str(), reason.c_str());
- ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
- }
- }
+ PROTORECVEVENT pre = { 0 };
+ pre.timestamp = time(0);
+ pre.lParam = blob.size();
+ pre.szMessage = blob;
+
+ ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
}
}
diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp
index 8a0869ab04..dc102efb8f 100644
--- a/protocols/SkypeWeb/src/skype_db.cpp
+++ b/protocols/SkypeWeb/src/skype_db.cpp
@@ -99,8 +99,6 @@ void CSkypeProto::EditEvent(MCONTACT hContact, MEVENT hEvent, const char *szCont
void CSkypeProto::InitDBEvents()
{
- db_set_resident(m_szModuleName, "LastAuthRequestTime");
-
// custom event
DBEVENTTYPEDESCR dbEventType = {};
dbEventType.module = m_szModuleName;
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 17f0f901eb..3d2280b506 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -47,15 +47,15 @@ void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpReque
std::string content = message["content"].as_string();
std::string conversationLink = message["conversationLink"].as_string();
int emoteOffset = message["skypeemoteoffset"].as_int();
- time_t timestamp = IsoToUnixTime(message["composetime"].as_string().c_str());
+ time_t timestamp = IsoToUnixTime(message["composetime"].as_string());
CMStringA skypename(UrlToSkypename(from.c_str()));
bool isEdited = message["skypeeditedid"];
MCONTACT hContact = FindContact(UrlToSkypename(conversationLink.c_str()));
- if (timestamp > db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0))
- db_set_dw(hContact, m_szModuleName, "LastMsgTime", (DWORD)timestamp);
+ if (timestamp > getDword(hContact, "LastMsgTime", 0))
+ setDword(hContact, "LastMsgTime", timestamp);
DWORD iFlags = DBEF_UTF;
@@ -138,7 +138,7 @@ void CSkypeProto::OnSyncHistory(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
if (strConversationLink.find("/8:") != -1) {
CMStringA szSkypename = UrlToSkypename(strConversationLink.c_str());
- time_t composeTime(IsoToUnixTime(lastMessage["composetime"].as_string().c_str()));
+ time_t composeTime(IsoToUnixTime(lastMessage["composetime"].as_string()));
MCONTACT hContact = FindContact(szSkypename);
if (hContact != NULL)
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index 773a6ec588..222c67e59a 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -108,7 +108,7 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
MCONTACT hContact = AddContact(szConversationName, true);
if (m_bHistorySynced)
- db_set_dw(hContact, m_szModuleName, "LastMsgTime", (DWORD)timestamp);
+ setDword(hContact, "LastMsgTime", timestamp);
if (strMessageType == "Control/Typing") {
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_INFINITE);
@@ -184,7 +184,7 @@ void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent)
db_event_get(hDbEvent, &dbei);
time_t timestamp = dbei.timestamp;
- if (db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0) > (timestamp - 300))
+ if (getDword(hContact, "LastMsgTime") > (timestamp - 300))
PushRequest(new MarkMessageReadRequest(getId(hContact), timestamp, timestamp, false));
}
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
index a9e4c0c737..c4d0f695c4 100644
--- a/protocols/SkypeWeb/src/skype_polling.cpp
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -152,13 +152,15 @@ void CSkypeProto::ProcessEndpointPresence(const JSONNode &node)
MirVer.Append("Skype (Unknown)");
}
}
+
if (privateInfo != NULL) {
std::string epname = privateInfo["epname"].as_string();
if (!epname.empty()) {
MirVer.AppendFormat(" [%s]", epname.c_str());
}
}
- db_set_s(hContact, m_szModuleName, "MirVer", MirVer);
+
+ setString(hContact, "MirVer", MirVer);
}
void CSkypeProto::ProcessUserPresence(const JSONNode &node)
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 343149dd4c..3facd417fc 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -316,7 +316,7 @@ private:
{ return (!mir_strcmpi(str, m_szMyname) || !mir_strcmp(str, ptrA(getStringA("SelfEndpointName"))));
}
- static time_t IsoToUnixTime(const char *stamp);
+ static time_t IsoToUnixTime(const std::string &stamp);
static CMStringA GetStringChunk(const char *haystack, const char *start, const char *end);
static int SkypeToMirandaStatus(const char *status);
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index 41815c55ec..2c088b2d37 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -19,15 +19,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma warning(disable:4566)
-time_t CSkypeProto::IsoToUnixTime(const char *stamp)
+time_t CSkypeProto::IsoToUnixTime(const std::string &stamp)
{
char date[9];
int i, y;
- if (stamp == nullptr)
+ if (stamp.empty())
return 0;
- char *p = NEWSTR_ALLOCA(stamp);
+ char *p = NEWSTR_ALLOCA(stamp.c_str());
// skip '-' chars
int si = 0, sj = 0;
diff --git a/protocols/SkypeWeb/src/version.h b/protocols/SkypeWeb/src/version.h
index bd5f11f803..c89475f2d6 100644
--- a/protocols/SkypeWeb/src/version.h
+++ b/protocols/SkypeWeb/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
#define __RELEASE_NUM 12
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>