1 /* 2 * Copyright 2012-2016 James Geboski <jgeboski@gmail.com> 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef _STEAM_USER_H_ 19 #define _STEAM_USER_H_ 20 21 /** 22 * SECTION:user 23 * @section_id: steam-user 24 * @short_description: <filename>steam-user.h</filename> 25 * @title: JSON Utilities 26 * 27 * The JSON utilities. 28 */ 29 30 #include <bitlbee.h> 31 32 #include "steam-glib.h" 33 #include "steam-id.h" 34 35 typedef struct _SteamUser SteamUser; 36 typedef struct _SteamUserInfo SteamUserInfo; 37 typedef struct _SteamUserMsg SteamUserMsg; 38 39 /** 40 * SteamUserAct: 41 * @STEAM_USER_ACT_REMOVE: Removed. 42 * @STEAM_USER_ACT_IGNORE: Ignored. 43 * @STEAM_USER_ACT_REQUEST: Friendship request. 44 * @STEAM_USER_ACT_ADD: Added. 45 * @STEAM_USER_ACT_REQUESTED: Requested friendship. 46 * @STEAM_USER_ACT_NONE: None. 47 * 48 * The #SteamUserInfo actions. 49 */ 50 typedef enum 51 { 52 STEAM_USER_ACT_REMOVE = 0, 53 STEAM_USER_ACT_IGNORE = 1, 54 STEAM_USER_ACT_REQUEST = 2, 55 STEAM_USER_ACT_ADD = 3, 56 STEAM_USER_ACT_REQUESTED = 4, 57 58 STEAM_USER_ACT_NONE 59 } SteamUserAct; 60 61 /** 62 * SteamUserMsgType: 63 * @STEAM_USER_MSG_TYPE_SAYTEXT: Say text. 64 * @STEAM_USER_MSG_TYPE_EMOTE: Emote. 65 * @STEAM_USER_MSG_TYPE_LEFT_CONV: Left conversation. 66 * @STEAM_USER_MSG_TYPE_RELATIONSHIP: Relationship. 67 * @STEAM_USER_MSG_TYPE_STATE: State. 68 * @STEAM_USER_MSG_TYPE_TYPING: Typing. 69 * @STEAM_USER_MSG_TYPE_MY_SAYTEXT: My say text. 70 * @STEAM_USER_MSG_TYPE_MY_EMOTE: My emote. 71 * @STEAM_USER_MSG_TYPE_UNKNOWN: Unknown. 72 * 73 * The #SteamUserMsg types. 74 */ 75 typedef enum 76 { 77 STEAM_USER_MSG_TYPE_SAYTEXT = 0, 78 STEAM_USER_MSG_TYPE_EMOTE, 79 STEAM_USER_MSG_TYPE_LEFT_CONV, 80 STEAM_USER_MSG_TYPE_RELATIONSHIP, 81 STEAM_USER_MSG_TYPE_STATE, 82 STEAM_USER_MSG_TYPE_TYPING, 83 STEAM_USER_MSG_TYPE_MY_SAYTEXT, 84 STEAM_USER_MSG_TYPE_MY_EMOTE, 85 86 STEAM_USER_MSG_TYPE_UNKNOWN 87 } SteamUserMsgType; 88 89 /** 90 * SteamUserRel: 91 * @STEAM_USER_REL_FRIEND: Friend. 92 * @STEAM_USER_REL_IGNORE: Ignored. 93 * 94 * The #SteamUserInfo relationships. 95 */ 96 typedef enum 97 { 98 STEAM_USER_REL_FRIEND = 0, 99 STEAM_USER_REL_IGNORE 100 } SteamUserRel; 101 102 /** 103 * SteamUserState: 104 * @STEAM_USER_STATE_OFFLINE: Offline. 105 * @STEAM_USER_STATE_ONLINE: Online. 106 * @STEAM_USER_STATE_BUSY: Busy. 107 * @STEAM_USER_STATE_AWAY: Away. 108 * @STEAM_USER_STATE_SNOOZE: Snooze. 109 * @STEAM_USER_STATE_TRADE: Trade. 110 * @STEAM_USER_STATE_PLAY: Play. 111 * 112 * The #SteamUserInfo states. 113 */ 114 typedef enum 115 { 116 STEAM_USER_STATE_OFFLINE = 0, 117 STEAM_USER_STATE_ONLINE = 1, 118 STEAM_USER_STATE_BUSY = 2, 119 STEAM_USER_STATE_AWAY = 3, 120 STEAM_USER_STATE_SNOOZE = 4, 121 STEAM_USER_STATE_TRADE = 5, 122 STEAM_USER_STATE_PLAY = 6 123 } SteamUserState; 124 125 /** 126 * SteamUserFlags: 127 * @STEAM_USER_FLAG_WEB: Using a web client. 128 * @STEAM_USER_FLAG_MOBILE: Using a mobile client. 129 * @STEAM_USER_FLAG_BIGPIC: Using Big Picture mode. 130 * 131 * The #SteamUserInfo flags. 132 */ 133 typedef enum 134 { 135 STEAM_USER_FLAG_WEB = 1 << 8, 136 STEAM_USER_FLAG_MOBILE = 1 << 9, 137 STEAM_USER_FLAG_BIGPIC = 1 << 10 138 } SteamUserFlags; 139 140 /** 141 * SteamUser: 142 * @buser: The #bee_user. 143 * @game: The game name or #NULL. 144 * @server: The game server or #NULL. 145 * @vtime: The last view timestamp (UTC). 146 * 147 * Represents a Steam user. 148 */ 149 struct _SteamUser 150 { 151 bee_user_t *buser; 152 gchar *game; 153 gchar *server; 154 gint64 vtime; 155 }; 156 157 /** 158 * SteamUserInfo: 159 * @id: The #SteamId. 160 * @nicks: The #GSList of prior nicknames. 161 * @state: The #SteamUserState. 162 * @flags: The #SteamUserFlags. 163 * @rel: The #SteamUserRel. 164 * @act: The #SteamUserAct. 165 * @nick: The nickname. 166 * @fullname: The full name. 167 * @game: The game name or #NULL. 168 * @server: The game server or #NULL. 169 * @profile: The profile URL or #NULL. 170 * @ltime: The last logoff timestamp (UTC). 171 * @vtime: The last view timestamp (UTC). 172 * @unread: The unread message count. 173 * 174 * Represents Steam user information. 175 */ 176 struct _SteamUserInfo 177 { 178 SteamId id; 179 GSList *nicks; 180 181 SteamUserState state; 182 SteamUserFlags flags; 183 SteamUserRel rel; 184 SteamUserAct act; 185 186 gchar *nick; 187 gchar *fullname; 188 gchar *game; 189 gchar *server; 190 gchar *profile; 191 192 gint64 ltime; 193 gint64 vtime; 194 guint unread; 195 }; 196 197 /** 198 * SteamUserMsg: 199 * @type: The #SteamUserMsgType. 200 * @info: The #SteamUserInfo. 201 * @text: The message text or #NULL. 202 * @time: The message timestamp (UTC). 203 * 204 * Represents a steam user messages. 205 */ 206 struct _SteamUserMsg 207 { 208 SteamUserMsgType type; 209 SteamUserInfo *info; 210 211 gchar *text; 212 gint64 time; 213 }; 214 215 /** 216 * steam_user_new: 217 * @bu: The #bee_user. 218 * 219 * Creates a new #SteamUser. The returned #SteamUser should be freed 220 * with #steam_user_free() when no longer needed. 221 * 222 * Returns: The #SteamUser. 223 */ 224 SteamUser * 225 steam_user_new(bee_user_t *bu); 226 227 /** 228 * steam_user_free: 229 * @user: The #SteamUser. 230 * 231 * Frees all memory used by the #SteamUser. 232 */ 233 void 234 steam_user_free(SteamUser *user); 235 236 /** 237 * steam_user_chans_msg: 238 * @user: The #SteamUser. 239 * @format: The format string. 240 * @...: The arguments for the format string. 241 * 242 * Sends a message to all channels which the #SteamUser is occupying 243 * with the sender being the #SteamUser. 244 */ 245 void 246 steam_user_chans_msg(SteamUser *user, const gchar *fmt, ...) 247 G_GNUC_PRINTF(2, 3); 248 249 /** 250 * steam_user_flags_str: 251 * @flags: The #SteamUserFlags. 252 * 253 * Gets the string representation of the #SteamUserFlags. The returned 254 * string should be freed with #g_free() when no longer needed. 255 * 256 * Returns: The string representation or #NULL on error. 257 */ 258 gchar * 259 steam_user_flags_str(SteamUserFlags flags); 260 261 /** 262 * steam_user_info_new: 263 * @id: The #SteamId. 264 * 265 * Creates a new #SteamUserInfo. The returned #SteamUserInfo should be 266 * freed with #steam_user_info_free() when no longer needed. 267 * 268 * Returns: The #SteamUserInfo or #NULL on error. 269 */ 270 SteamUserInfo * 271 steam_user_info_new(SteamId id); 272 273 /** 274 * steam_user_info_free: 275 * @info: The #SteamUserInfo. 276 * 277 * Frees all memory used by the #SteamUserInfo. 278 */ 279 void 280 steam_user_info_free(SteamUserInfo *info); 281 282 283 /** 284 * steam_user_msg_new: 285 * @id: The #SteamId. 286 * 287 * Creates a new #SteamUserMsg. The returned #SteamUserMsg should be 288 * freed with #steam_user_msg_free() when no longer needed. 289 * 290 * Returns: The #SteamUserMsg. 291 */ 292 SteamUserMsg * 293 steam_user_msg_new(SteamId id); 294 295 /** 296 * steam_user_msg_free: 297 * @msg: The #SteamUserMsg. 298 * 299 * Frees all memory used by the #SteamUserMsg. 300 */ 301 void 302 steam_user_msg_free(SteamUserMsg *msg); 303 304 /** 305 * steam_user_msg_type_str: 306 * @type: The #SteamUserMsgType. 307 * 308 * Gets the string representation of the #SteamUserMsgType. 309 * 310 * Returns: The string representation or #NULL on error. 311 */ 312 const gchar * 313 steam_user_msg_type_str(SteamUserMsgType type); 314 315 /** 316 * steam_user_msg_type_from_str: 317 * @type: The string. 318 * 319 * Gets the #SteamUserMsgType value of the string. 320 * 321 * Returns: The #SteamUserMsgType value. 322 */ 323 SteamUserMsgType 324 steam_user_msg_type_from_str(const gchar *type); 325 326 /** 327 * steam_user_state_str: 328 * @state: The #SteamUserState. 329 * 330 * Gets the string representation of the #SteamUserState. 331 * 332 * Returns: The string representation or #NULL on error. 333 */ 334 const gchar * 335 steam_user_state_str(SteamUserState state); 336 337 #endif /* _STEAM_USER_H_ */ 338