# HG changeset patch # User Jeffrey Connelly # Date 1180759559 0 # Node ID 58b4d103a5b8176d613da3c2963cd6a5e7893ae0 # Parent 4f54e8c410861364656fd7ba3fe92ca00ee5abf7 Use symbolic constants for persist messages. diff -r 4f54e8c41086 -r 58b4d103a5b8 libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c Sat Jun 02 03:26:06 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.c Sat Jun 02 04:45:59 2007 +0000 @@ -34,6 +34,7 @@ #define PURPLE_PLUGIN #include "message.h" +#include "persist.h" #include "myspace.h" /** @@ -886,7 +887,8 @@ username = g_hash_table_lookup(body, "UserName"); if (username) { - /* TODO: permanently associated with blist item, if in buddy in blist */ + /* TODO: permanently associated with blist item, if in buddy in blist, + * See purple_blist_node_set_int(). */ g_hash_table_insert(session->user_lookup_cache, g_strdup(username), body); } else { purple_debug_info("msim", @@ -1409,22 +1411,21 @@ /* Send request */ - cmd = 1; + cmd = MSIM_CMD_GET; if (msim_is_userid(user)) { - /* TODO: document cmd,dsn,lid */ field_name = "UserID"; - dsn = 4; - lid = 3; + dsn = MG_MYSPACE_INFO_BY_ID_DSN; + lid = MG_MYSPACE_INFO_BY_ID_LID; } else if (msim_is_email(user)) { field_name = "Email"; - dsn = 5; - lid = 7; + dsn = MG_MYSPACE_INFO_BY_STRING_DSN; + lid = MG_MYSPACE_INFO_BY_STRING_LID; } else { field_name = "UserName"; - dsn = 5; - lid = 7; + dsn = MG_MYSPACE_INFO_BY_STRING_DSN; + lid = MG_MYSPACE_INFO_BY_STRING_LID; } diff -r 4f54e8c41086 -r 58b4d103a5b8 libpurple/protocols/myspace/myspace.h --- a/libpurple/protocols/myspace/myspace.h Sat Jun 02 03:26:06 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.h Sat Jun 02 04:45:59 2007 +0000 @@ -1,6 +1,4 @@ -/* MySpaceIM Protocol Plugin, headr file - * - * \author Jeff Connelly +/* MySpaceIM Protocol Plugin, header file * * Copyright (C) 2007, Jeff Connelly * diff -r 4f54e8c41086 -r 58b4d103a5b8 libpurple/protocols/myspace/persist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/myspace/persist.h Sat Jun 02 04:45:59 2007 +0000 @@ -0,0 +1,85 @@ +/* MySpaceIM Protocol Plugin, persist commands + * + * Copyright (C) 2007, Jeff Connelly + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MYSPACE_PERSIST_H +#define _MYSPACE_PERSIST_H + +/** Command codes */ +#define MSIM_CMD_GET 1 +#define MSIM_CMD_PUT 2 +#define MSIM_CMD_DELETE 3 + +/** Command bit fields */ +#define MSIM_CMD_BIT_CODE 255 /*< Bits specifying command code */ +#define MSIM_CMD_BIT_REPLY 256 /**< 1=reply, 0=request */ +#define MSIM_CMD_BIT_ACTION 512 /**< 1=action, 0=information */ +#define MSIM_CMD_BIT_ERROR 1024 /**< 1=error, 0=normal */ + +/** Macros to read cmd bitfield. */ +#define MSIM_CMD_GET_CODE(x) (x & MSIM_CMD_BIT_CODE) +#define MSIM_CMD_IS_REPLY(x) (x & MSIM_CMD_BIT_REPLY) +#define MSIM_CMD_IS_REQUEST(x) !(x & MSIM_CMD_BIT_REPLY) +#define MSIM_CMD_IS_ACTION(x) (x & MSIM_CMD_BIT_ACTION) +#define MSIM_CMD_IS_INFO(x) !(x & MSIM_CMD_BIT_ACTION) +#define MSIM_CMD_IS_ERROR(x) (x & MSIM_CMD_BIT_ERROR) +#define MSIM_CMD_IS_NORMAL(x) !(x & MSIM_CMD_BIT_ERROR) + +/** Define a set of _DSN and _LID constants for a persistance request. */ +#define MSIM_PERSIST_DSN_LID(name,dsn,lid) \ + const int name##_DSN = dsn; \ + const int name##_LID = lid; + +/* Can't do this, errors: + * persist.h:51:3: error: '#' is not followed by a macro parameter + * In file included from myspace.c:37: + * persist.h:56: error: expected ')' before numeric constant + * So instead, I define const ints above. +#define MSIM_PERSIST_DSN_LID(name,dsn,lid) \ + #define name##_DSN dsn \ + #define name##_LID lid +#endif +*/ + +/** Messages to Get information */ +MSIM_PERSIST_DSN_LID(MG_LIST_ALL_CONTACTS, 0, 1) +MSIM_PERSIST_DSN_LID(MG_USER_INFO_BY_ID, 0, 2) +MSIM_PERSIST_DSN_LID(MG_IM_INFO_BY_ID, 1, 17) +MSIM_PERSIST_DSN_LID(MG_LIST_ALL_GROUPS, 2, 6) +MSIM_PERSIST_DSN_LID(MG_MYSPACE_INFO_BY_ID, 4, 3) +MSIM_PERSIST_DSN_LID(MG_YOUR_MYSPACE_INFO, 4, 5) +MSIM_PERSIST_DSN_LID(MG_MYSPACE_INFO_BY_STRING, 5, 7) +MSIM_PERSIST_DSN_LID(MG_CHECK_MAIL, 7, 18) +MSIM_PERSIST_DSN_LID(MG_WEB_CHALLENGE, 17, 26) +MSIM_PERSIST_DSN_LID(MG_USER_SONG, 21, 28) +MSIM_PERSIST_DSN_LID(MG_SERVER_INFO, 101, 20) + +/** Messages to Change/send information */ +MSIM_PERSIST_DSN_LID(MC_USER_PREFERENCES, 1, 10) +MSIM_PERSIST_DSN_LID(MC_CONTACT_INFO, 0, 9) +MSIM_PERSIST_DSN_LID(MC_INVITE, 16, 25) + +/** Error codes */ +#define MERR_PARSE 1 +#define MERR_NOT_LOGGED_IN 2 +#define MERR_ANOTHER_LOGIN 6 +#define MERR_BAD_EMAIL 259 +#define MERR_BAD_PASSWORD 260 +#define MERR_BAD_UID_IN_PERSISTR 4352 + +#endif /* !_MYSPACE_PERSIST_H */