Mercurial > pidgin.yaz
comparison libpurple/protocols/msnp9/state.c @ 21312:a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
old fools like me who prefer the stability of our MSNP9 code over the
features of MSNP14 can enable this using the --disable-msnp14 ./configure
option.
If we want to release from i.p.p and MSN stability is the only blocker, we
can trivially flick the default to use MSNP9 in configure.ac
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 11 Nov 2007 12:57:52 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
21311:7d031cec5ba2 | 21312:a07cfce78345 |
---|---|
1 /** | |
2 * @file state.c State functions and definitions | |
3 * | |
4 * purple | |
5 * | |
6 * Purple is the legal property of its developers, whose names are too numerous | |
7 * to list here. Please refer to the COPYRIGHT file distributed with this | |
8 * source distribution. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
23 */ | |
24 #include "msn.h" | |
25 #include "state.h" | |
26 | |
27 static const char *away_text[] = | |
28 { | |
29 N_("Available"), | |
30 N_("Available"), | |
31 N_("Busy"), | |
32 N_("Idle"), | |
33 N_("Be Right Back"), | |
34 N_("Away From Computer"), | |
35 N_("On The Phone"), | |
36 N_("Out To Lunch"), | |
37 N_("Available"), | |
38 N_("Available") | |
39 }; | |
40 | |
41 void | |
42 msn_change_status(MsnSession *session) | |
43 { | |
44 PurpleAccount *account; | |
45 MsnCmdProc *cmdproc; | |
46 MsnUser *user; | |
47 MsnObject *msnobj; | |
48 const char *state_text; | |
49 | |
50 g_return_if_fail(session != NULL); | |
51 g_return_if_fail(session->notification != NULL); | |
52 | |
53 account = session->account; | |
54 cmdproc = session->notification->cmdproc; | |
55 user = session->user; | |
56 state_text = msn_state_get_text(msn_state_from_account(account)); | |
57 | |
58 /* If we're not logged in yet, don't send the status to the server, | |
59 * it will be sent when login completes | |
60 */ | |
61 if (!session->logged_in) | |
62 return; | |
63 | |
64 msnobj = msn_user_get_object(user); | |
65 | |
66 if (msnobj == NULL) | |
67 { | |
68 msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text, | |
69 MSN_CLIENT_ID); | |
70 } | |
71 else | |
72 { | |
73 char *msnobj_str; | |
74 | |
75 msnobj_str = msn_object_to_string(msnobj); | |
76 | |
77 msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state_text, | |
78 MSN_CLIENT_ID, purple_url_encode(msnobj_str)); | |
79 | |
80 g_free(msnobj_str); | |
81 } | |
82 } | |
83 | |
84 const char * | |
85 msn_away_get_text(MsnAwayType type) | |
86 { | |
87 g_return_val_if_fail(type <= MSN_HIDDEN, NULL); | |
88 | |
89 return _(away_text[type]); | |
90 } | |
91 | |
92 const char * | |
93 msn_state_get_text(MsnAwayType state) | |
94 { | |
95 static char *status_text[] = | |
96 { "NLN", "NLN", "BSY", "IDL", "BRB", "AWY", "PHN", "LUN", "HDN", "HDN" }; | |
97 | |
98 return status_text[state]; | |
99 } | |
100 | |
101 MsnAwayType | |
102 msn_state_from_account(PurpleAccount *account) | |
103 { | |
104 MsnAwayType msnstatus; | |
105 PurplePresence *presence; | |
106 PurpleStatus *status; | |
107 const char *status_id; | |
108 | |
109 presence = purple_account_get_presence(account); | |
110 status = purple_presence_get_active_status(presence); | |
111 status_id = purple_status_get_id(status); | |
112 | |
113 if (!strcmp(status_id, "away")) | |
114 msnstatus = MSN_AWAY; | |
115 else if (!strcmp(status_id, "brb")) | |
116 msnstatus = MSN_BRB; | |
117 else if (!strcmp(status_id, "busy")) | |
118 msnstatus = MSN_BUSY; | |
119 else if (!strcmp(status_id, "phone")) | |
120 msnstatus = MSN_PHONE; | |
121 else if (!strcmp(status_id, "lunch")) | |
122 msnstatus = MSN_LUNCH; | |
123 else if (!strcmp(status_id, "invisible")) | |
124 msnstatus = MSN_HIDDEN; | |
125 else | |
126 msnstatus = MSN_ONLINE; | |
127 | |
128 if ((msnstatus == MSN_ONLINE) && purple_presence_is_idle(presence)) | |
129 msnstatus = MSN_IDLE; | |
130 | |
131 return msnstatus; | |
132 } |