summaryrefslogtreecommitdiff
path: root/protocols/Tlen/src/tlen_presence.cpp
diff options
context:
space:
mode:
authorSzymon Tokarz <wsx22@o2.pl>2014-01-24 01:02:07 +0000
committerSzymon Tokarz <wsx22@o2.pl>2014-01-24 01:02:07 +0000
commit43f04f0fcb082fb2c7f69617101e6147c81cf0d3 (patch)
tree6ef3bfb716719e3fe7a0640dbad9f859619c9e7a /protocols/Tlen/src/tlen_presence.cpp
parent259bd5726faf89964ff6ee7ec0858d39ff6ac170 (diff)
Tlen protocol
- Support case when user account is added as contact (show status and status msg on clist) - try to improve fetching avatars and setting own avatar - minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@7846 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tlen/src/tlen_presence.cpp')
-rw-r--r--protocols/Tlen/src/tlen_presence.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/protocols/Tlen/src/tlen_presence.cpp b/protocols/Tlen/src/tlen_presence.cpp
index 4d20d08f6a..617ec7e2ca 100644
--- a/protocols/Tlen/src/tlen_presence.cpp
+++ b/protocols/Tlen/src/tlen_presence.cpp
@@ -72,8 +72,10 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
else
p = NULL;
TlenListAddResource(proto, LIST_ROSTER, from, status, statusNode?p:NULL);
- if (p) {
- db_set_s(hContact, "CList", "StatusMsg", p);
+ if (p != NULL && *p) {
+ char* statusMsg_utf8 = mir_utf8encode(p);
+ db_set_utf(hContact, "CList", "StatusMsg", statusMsg_utf8);
+ mir_free(statusMsg_utf8);
mir_free(p);
} else {
db_unset(hContact, "CList", "StatusMsg");
@@ -121,8 +123,10 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
p = TlenTextDecode(statusNode->text);
TlenListAddResource(proto, LIST_ROSTER, from, status, p);
if ((hContact=TlenHContactFromJID(proto, from)) != NULL) {
- if (p) {
- db_set_s(hContact, "CList", "StatusMsg", p);
+ if (p != NULL && *p) {
+ char* statusMsg_utf8 = mir_utf8encode(p);
+ db_set_utf(hContact, "CList", "StatusMsg", statusMsg_utf8);
+ mir_free(statusMsg_utf8);
} else {
db_unset(hContact, "CList", "StatusMsg");
}
@@ -170,6 +174,24 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto)
}
}
+/* change status and status msg on own contact on contact list (if present) */
+void setOwnStatusOnCList(TlenProtocol *proto, int status, char *statusMsg)
+{
+ ptrA ownJid(db_get_sa(NULL, proto->m_szModuleName, "jid"));
+ HANDLE hContact = TlenHContactFromJID(proto, ownJid);
+ if(hContact){
+ if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != status)
+ db_set_w(hContact, proto->m_szModuleName, "Status", (WORD)status);
+ if (statusMsg != NULL && *statusMsg) {
+ char* statusMsg_utf8 = mir_utf8encode(statusMsg);
+ db_set_utf(hContact, "CList", "StatusMsg", statusMsg_utf8);
+ mir_free(statusMsg_utf8);
+ } else {
+ db_unset(hContact, "CList", "StatusMsg");
+ }
+ }
+}
+
static void TlenSendPresenceTo(TlenProtocol *proto, int status, char *to)
{
char *showBody, *statusMsg, *presenceType;
@@ -264,6 +286,7 @@ static void TlenSendPresenceTo(TlenProtocol *proto, int status, char *to)
}
}
}
+ mir_free(statusMsg);
statusMsg = ptr;
break;
default:
@@ -272,19 +295,19 @@ static void TlenSendPresenceTo(TlenProtocol *proto, int status, char *to)
}
proto->m_iStatus = status;
if (presenceType) {
- if (statusMsg)
- TlenSend(proto, "<presence type='%s'><status>%s</status></presence>", presenceType, statusMsg);
+ if (statusMsg != NULL && *statusMsg)
+ TlenSend(proto, "<presence type='%s'><status>%s</status></presence>", presenceType, ptrA(TlenTextEncode(statusMsg)));
else
TlenSend(proto, "<presence type='%s'></presence>", presenceType);
} else {
- if (statusMsg)
- TlenSend(proto, "<presence><show>%s</show><status>%s</status></presence>", showBody, statusMsg);
+ if (statusMsg != NULL && *statusMsg)
+ TlenSend(proto, "<presence><show>%s</show><status>%s</status></presence>", showBody, ptrA(TlenTextEncode(statusMsg)));
else
TlenSend(proto, "<presence><show>%s</show></presence>", showBody);
}
- if (ptr) {
- mir_free(ptr);
- }
+
+ setOwnStatusOnCList(proto, proto->m_iStatus, statusMsg);
+
LeaveCriticalSection(&proto->modeMsgMutex);
}