summaryrefslogtreecommitdiff
path: root/MySpace/server_con.cpp
diff options
context:
space:
mode:
author(no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10>2008-06-02 05:52:07 +0000
committer(no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10>2008-06-02 05:52:07 +0000
commit389f409a4b7c4243435ffdd11e39f225965a5a61 (patch)
tree336485ddede887b1f44037f68c25e812630b0cd7 /MySpace/server_con.cpp
parentbbdabe234691ad14c975661376e4e89c6650cdb8 (diff)
store contacts properly on server side, so that status is reported
added code to store all old contacts to fix old server side contact lists updated version.h git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@409 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'MySpace/server_con.cpp')
-rw-r--r--MySpace/server_con.cpp80
1 files changed, 59 insertions, 21 deletions
diff --git a/MySpace/server_con.cpp b/MySpace/server_con.cpp
index 2b524e7..4c295c0 100644
--- a/MySpace/server_con.cpp
+++ b/MySpace/server_con.cpp
@@ -133,6 +133,58 @@ int LookupUID(int uid) {
return ret;
}
+void AddAllContactsToServer() {
+ char *proto;
+ int uid;
+ HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 );
+ while ( hContact != NULL )
+ {
+ proto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 );
+ if ( proto && !strcmp( MODULE, proto)) {
+ uid = DBGetContactSettingDword(hContact, MODULE, "UID", (DWORD)0);
+ AddBuddyOnServer(uid);
+ }
+ hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 );
+ }
+}
+
+void AddBuddyOnServer(int uid) {
+ ClientNetMessage msg_add;
+ msg_add.add_string("addbuddy", "");
+ msg_add.add_int("sesskey", sesskey);
+ msg_add.add_int("newprofileid", uid);
+ msg_add.add_string("reason", "");
+
+ SendMessage(msg_add);
+
+ // update block list
+ ClientNetMessage msg_block;
+ msg_block.add_string("blocklist", "");
+ msg_block.add_int("sesskey", sesskey);
+
+ char idlist[1024];
+ mir_snprintf(idlist, 1024, "b-|%d|a+|%d", uid, uid);
+ msg_block.add_string("idlist", idlist);
+
+ SendMessage(msg_block);
+
+ // update server side list?
+ ClientNetMessage msg_srvlist;
+ msg_srvlist.add_int("persist", 1);
+ msg_srvlist.add_int("sesskey", sesskey);
+ msg_srvlist.add_int("cmd", 514);
+ msg_srvlist.add_int("dsn", 0);
+ msg_srvlist.add_int("uid", my_uid);
+ msg_srvlist.add_int("lid", 9);
+ msg_srvlist.add_int("rid", 31);
+
+ char body[1024];
+ mir_snprintf(body, 1024, "ContactID=%d", uid);
+ msg_srvlist.add_string("body", body);
+
+ SendMessage(msg_srvlist);
+}
+
HANDLE CreateContact(int uid, char *nick, char *email, bool add_buddy) {
HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
@@ -146,27 +198,7 @@ HANDLE CreateContact(int uid, char *nick, char *email, bool add_buddy) {
}
- if(add_buddy) {
- ClientNetMessage msg_add;
- msg_add.add_string("addbuddy", "");
- msg_add.add_int("sesskey", sesskey);
- msg_add.add_int("newprofileid", uid);
- msg_add.add_string("reason", "");
-
- SendMessage(msg_add);
- }
-
- /*
- ClientNetMessage msg_block;
- msg_block.add_string("blocklist", "");
- msg_block.add_int("sesskey", sesskey);
-
- char idlist[1024];
- mir_snprintf(idlist, 1024, "b-|%d|a+|%d", mpsr->uid, mpsr->uid);
- msg_block.add_string("idlist", idlist);
-
- SendMessage(msg_block);
- */
+ if(add_buddy) AddBuddyOnServer(uid);
/*
// update contact details?
@@ -474,6 +506,12 @@ void __cdecl ServerThreadFunc(void*) {
msg_setinfo.add_dict("info", ld);
SendMessage(msg_setinfo);
*/
+
+ // add all contacts to server (old versions didn't do it :| )
+ if(DBGetContactSettingByte(0, MODULE, "ContactsOnServer", 0) == 0) {
+ AddAllContactsToServer();
+ DBWriteContactSettingByte(0, MODULE, "ContactsOnServer", 1);
+ }
// start mail checking thread
mir_forkthread(CheckMailThreadFunc, 0);