Mercurial > pidgin.yaz
changeset 5361:953aa05279f4
[gaim-migrate @ 5737]
Merged the state code and away code into state.[ch].
You can now see what users are using MSN Mobile.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 13 May 2003 02:51:13 +0000 |
parents | ba459635b075 |
children | a206742d470d |
files | src/protocols/msn/Makefile.am src/protocols/msn/away.c src/protocols/msn/away.h src/protocols/msn/msn.c src/protocols/msn/notification.c src/protocols/msn/state.c src/protocols/msn/state.h |
diffstat | 7 files changed, 162 insertions(+), 108 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/msn/Makefile.am Mon May 12 15:10:47 2003 +0000 +++ b/src/protocols/msn/Makefile.am Tue May 13 02:51:13 2003 +0000 @@ -3,8 +3,6 @@ pkgdir = $(libdir)/gaim MSNSOURCES = \ - away.c \ - away.h \ buddyicon.c \ buddyicon.h \ dispatch.c \ @@ -22,6 +20,8 @@ servconn.h \ session.c \ session.h \ + state.c \ + state.h \ switchboard.c \ switchboard.h \ user.c \
--- a/src/protocols/msn/away.c Mon May 12 15:10:47 2003 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/** - * @file away.c Away functions - * - * gaim - * - * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> - * - * 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 - */ -#include "msn.h" -#include "away.h" - -static const char *away_text[] = -{ - N_("Available"), - N_("Available"), - N_("Busy"), - N_("Idle"), - N_("Be Right Back"), - N_("Away From Computer"), - N_("On The Phone"), - N_("Out To Lunch"), - N_("Available"), - N_("Available") -}; - -const char * -msn_away_get_text(MsnAwayType type) -{ - g_return_val_if_fail(type >= 0 && type <= MSN_HIDDEN, NULL); - - return away_text[type]; -}
--- a/src/protocols/msn/away.h Mon May 12 15:10:47 2003 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/** - * @file away.h Away functions - * - * gaim - * - * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> - * - * 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 _MSN_AWAY_H_ -#define _MSN_AWAY_H_ - -/** - * Away types. - */ -typedef enum -{ - MSN_ONLINE = 1, - MSN_BUSY = 2, - MSN_IDLE = 3, - MSN_BRB = 4, - MSN_AWAY = 5, - MSN_PHONE = 6, - MSN_LUNCH = 7, - MSN_OFFLINE = 8, - MSN_HIDDEN = 9 - -} MsnAwayType; - -/** - * Returns the string representation of an away type. - * - * @param type The away type. - * - * @return The string representation of the away type. - */ -const char *msn_away_get_text(MsnAwayType type); - -#endif /* _MSN_AWAY_H_ */
--- a/src/protocols/msn/msn.c Mon May 12 15:10:47 2003 +0000 +++ b/src/protocols/msn/msn.c Tue May 13 02:51:13 2003 +0000 @@ -20,9 +20,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "msn.h" -#include "away.h" #include "msg.h" #include "session.h" +#include "state.h" #include "utils.h" #define BUDDY_ALIAS_MAXLEN 388 @@ -88,19 +88,31 @@ msn_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) { + char *emblems[4] = { NULL, NULL, NULL, NULL }; + int away_type = MSN_AWAY_TYPE(b->uc); + int i = 0; + if (b->present == GAIM_BUDDY_OFFLINE) - *se = "offline"; - else if ((b->uc >> 1) == 2 || (b->uc >> 1) == 6) - *se = "occupied"; - else if (b->uc) - *se = "away"; + emblems[i++] = "offline"; + else if (away_type == MSN_BUSY || away_type == MSN_PHONE) + emblems[i++] = "occupied"; + else if (away_type != 0) + emblems[i++] = "away"; + + if (MSN_MOBILE(b->uc)) + emblems[i++] = "wireless"; + + *se = emblems[0]; + *sw = emblems[1]; + *nw = emblems[2]; + *ne = emblems[3]; } static char * msn_status_text(struct buddy *b) { if (b->uc & UC_UNAVAILABLE) - return g_strdup(msn_away_get_text(b->uc >> 1)); + return g_strdup(msn_away_get_text(MSN_AWAY_TYPE(b->uc))); return NULL; } @@ -110,7 +122,7 @@ { if (GAIM_BUDDY_IS_ONLINE(b)) { return g_strdup_printf(_("<b>Status:</b> %s"), - msn_away_get_text(b->uc >> 1)); + msn_away_get_text(MSN_AWAY_TYPE(b->uc))); } return NULL;
--- a/src/protocols/msn/notification.c Mon May 12 15:10:47 2003 +0000 +++ b/src/protocols/msn/notification.c Tue May 13 02:51:13 2003 +0000 @@ -21,7 +21,7 @@ */ #include "msn.h" #include "notification.h" -#include "away.h" +#include "state.h" #include "error.h" #include "utils.h" @@ -428,6 +428,34 @@ } static gboolean +__bpr_cmd(MsnServConn *servconn, const char *command, const char **params, + size_t param_count) +{ + struct gaim_connection *gc = servconn->session->account->gc; + struct buddy *b; + const char *passport, *type, *value; + int status = 0; + + passport = params[1]; + type = params[2]; + value = params[3]; + + if (!strcmp(type, "MOB")) { + if (value != NULL && !strcmp(value, "Y")) { + gaim_debug(GAIM_DEBUG_MISC, "msn", + "%s has a pager\n", passport); + if ((b = gaim_find_buddy(gc->account, passport)) != NULL) { + status = b->uc | (1 << 5); + + serv_got_update(gc, (char *)passport, 1, 0, 0, 0, status); + } + } + } + + return TRUE; +} + +static gboolean __fln_cmd(MsnServConn *servconn, const char *command, const char **params, size_t param_count) { @@ -445,6 +473,7 @@ struct gaim_connection *gc = servconn->session->account->gc; int status = 0; const char *state, *passport, *friend; + struct buddy *b; state = params[1]; passport = params[2]; @@ -452,6 +481,9 @@ serv_got_alias(gc, (char *)passport, (char *)friend); + if ((b = gaim_find_buddy(gc->account, passport)) != NULL) + status |= ((((b->uc) >> 1) & 0xF0) << 1); + if (!g_ascii_strcasecmp(state, "BSY")) status |= UC_UNAVAILABLE | (MSN_BUSY << 1); else if (!g_ascii_strcasecmp(state, "IDL")) @@ -1197,7 +1229,7 @@ msn_servconn_register_command(notification, "ADD", __add_cmd); msn_servconn_register_command(notification, "ADG", __adg_cmd); msn_servconn_register_command(notification, "BLP", __blp_cmd); - msn_servconn_register_command(notification, "BPR", __blank_cmd); + msn_servconn_register_command(notification, "BPR", __bpr_cmd); msn_servconn_register_command(notification, "CHG", __blank_cmd); msn_servconn_register_command(notification, "CHL", __chl_cmd); msn_servconn_register_command(notification, "FLN", __fln_cmd);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/protocols/msn/state.c Tue May 13 02:51:13 2003 +0000 @@ -0,0 +1,45 @@ +/** + * @file state.c State functions and definitions + * + * gaim + * + * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> + * + * 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 + */ +#include "msn.h" +#include "state.h" + +static const char *away_text[] = +{ + N_("Available"), + N_("Available"), + N_("Busy"), + N_("Idle"), + N_("Be Right Back"), + N_("Away From Computer"), + N_("On The Phone"), + N_("Out To Lunch"), + N_("Available"), + N_("Available") +}; + +const char * +msn_away_get_text(MsnAwayType type) +{ + g_return_val_if_fail(type >= 0 && type <= MSN_HIDDEN, NULL); + + return away_text[type]; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/protocols/msn/state.h Tue May 13 02:51:13 2003 +0000 @@ -0,0 +1,61 @@ +/** + * @file state.h State functinos and definitions + * + * gaim + * + * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> + * + * 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 _MSN_STATE_H_ +#define _MSN_STATE_H_ + +/** + * Away types. + */ +typedef enum +{ + MSN_ONLINE = 1, + MSN_BUSY = 2, + MSN_IDLE = 3, + MSN_BRB = 4, + MSN_AWAY = 5, + MSN_PHONE = 6, + MSN_LUNCH = 7, + MSN_OFFLINE = 8, + MSN_HIDDEN = 9 + +} MsnAwayType; + +/* + * 0 0 0 0 0 0 0 0 + * | `--_--' + * | +----- Away state + * | + * +--- Mobile flag + */ +#define MSN_AWAY_TYPE(x) (((x) >> 1) & 0x0F) +#define MSN_MOBILE(x) (((x) >> 5) & 0x01) + +/** + * Returns the string representation of an away type. + * + * @param type The away type. + * + * @return The string representation of the away type. + */ +const char *msn_away_get_text(MsnAwayType type); + +#endif /* _MSN_STATE_H_ */