1 /* 2 3 silcpurple.h 4 5 Author: Pekka Riikonen <priikone@silcnet.org> 6 7 Copyright (C) 2004 - 2007 Pekka Riikonen 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; version 2 of the License. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 */ 19 20 #ifndef SILCPURPLE_H 21 #define SILCPURPLE_H 22 23 /* Purple includes */ 24 #include "internal.h" 25 #include "account.h" 26 #include "accountopt.h" 27 #include "cmds.h" 28 #include "conversation.h" 29 #include "debug.h" 30 #include "ft.h" 31 #include "notify.h" 32 #include "prpl.h" 33 #include "request.h" 34 #include "roomlist.h" 35 #include "server.h" 36 #include "util.h" 37 38 #undef SILC_VERSION 39 #define SILC_VERSION(a, b, c) (((a) << 24) + ((b) << 16) + ((c) << 8)) 40 41 /* Default public and private key file names */ 42 #define SILCPURPLE_PUBLIC_KEY_NAME "public_key.pub" 43 #define SILCPURPLE_PRIVATE_KEY_NAME "private_key.prv" 44 45 /* Default settings for creating key pair */ 46 #define SILCPURPLE_DEF_PKCS "rsa" 47 #define SILCPURPLE_DEF_PKCS_LEN 2048 48 49 #define SILCPURPLE_PRVGRP 0x001fffff 50 51 /* Status IDs */ 52 #define SILCPURPLE_STATUS_ID_OFFLINE "offline" 53 #define SILCPURPLE_STATUS_ID_AVAILABLE "available" 54 #define SILCPURPLE_STATUS_ID_HYPER "hyper" 55 #define SILCPURPLE_STATUS_ID_AWAY "away" 56 #define SILCPURPLE_STATUS_ID_BUSY "busy" 57 #define SILCPURPLE_STATUS_ID_INDISPOSED "indisposed" 58 #define SILCPURPLE_STATUS_ID_PAGE "page" 59 60 typedef struct { 61 unsigned long id; 62 const char *channel; 63 unsigned long chid; 64 const char *parentch; 65 SilcChannelPrivateKey key; 66 } *SilcPurplePrvgrp; 67 68 /* The SILC Purple plugin context */ 69 typedef struct SilcPurpleStruct { 70 SilcClient client; 71 SilcClientConnection conn; 72 SilcPublicKey public_key; 73 SilcPrivateKey private_key; 74 SilcHash sha1hash; 75 76 SilcDList tasks; 77 guint scheduler; 78 PurpleConnection *gc; 79 PurpleAccount *account; 80 unsigned long channel_ids; 81 GList *grps; 82 83 char *motd; 84 PurpleRoomlist *roomlist; 85 SilcMimeAssembler mimeass; 86 unsigned int detaching : 1; 87 unsigned int resuming : 1; 88 unsigned int roomlist_cancelled : 1; 89 unsigned int chpk : 1; 90 } *SilcPurple; 91 92 93 void silc_say(SilcClient client, SilcClientConnection conn, 94 SilcClientMessageType type, char *msg, ...); 95 SilcBool silcpurple_command_reply(SilcClient client, SilcClientConnection conn, 96 SilcCommand command, SilcStatus status, 97 SilcStatus error, void *context, va_list ap); 98 gboolean silcpurple_check_silc_dir(PurpleConnection *gc); 99 const char *silcpurple_silcdir(void); 100 const char *silcpurple_session_file(const char *account); 101 void silcpurple_verify_public_key(SilcClient client, SilcClientConnection conn, 102 const char *name, 103 SilcConnectionType conn_type, 104 SilcPublicKey public_key, 105 SilcVerifyPublicKey completion, 106 void *context); 107 GList *silcpurple_buddy_menu(PurpleBuddy *buddy); 108 void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group); 109 void silcpurple_send_buddylist(PurpleConnection *gc); 110 void silcpurple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group); 111 void silcpurple_buddy_keyagr_request(SilcClient client, 112 SilcClientConnection conn, 113 SilcClientEntry client_entry, 114 const char *hostname, SilcUInt16 port, 115 SilcUInt16 protocol); 116 void silcpurple_idle_set(PurpleConnection *gc, int idle); 117 void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full); 118 char *silcpurple_status_text(PurpleBuddy *b); 119 gboolean silcpurple_ip_is_private(const char *ip); 120 void silcpurple_ftp_send_file(PurpleConnection *gc, const char *name, const char *file); 121 PurpleXfer *silcpurple_ftp_new_xfer(PurpleConnection *gc, const char *name); 122 void silcpurple_ftp_request(SilcClient client, SilcClientConnection conn, 123 SilcClientEntry client_entry, SilcUInt32 session_id, 124 const char *hostname, SilcUInt16 port); 125 void silcpurple_show_public_key(SilcPurple sg, 126 const char *name, SilcPublicKey public_key, 127 GCallback callback, void *context); 128 void silcpurple_get_info(PurpleConnection *gc, const char *who); 129 SilcAttributePayload 130 silcpurple_get_attr(SilcDList attrs, SilcAttribute attribute); 131 void silcpurple_get_umode_string(SilcUInt32 mode, char *buf, 132 SilcUInt32 buf_size); 133 void silcpurple_get_chmode_string(SilcUInt32 mode, char *buf, 134 SilcUInt32 buf_size); 135 void silcpurple_get_chumode_string(SilcUInt32 mode, char *buf, 136 SilcUInt32 buf_size); 137 GList *silcpurple_chat_info(PurpleConnection *gc); 138 GHashTable *silcpurple_chat_info_defaults(PurpleConnection *gc, const char *chat_name); 139 GList *silcpurple_chat_menu(PurpleChat *); 140 void silcpurple_chat_join(PurpleConnection *gc, GHashTable *data); 141 char *silcpurple_get_chat_name(GHashTable *data); 142 void silcpurple_chat_invite(PurpleConnection *gc, int id, const char *msg, 143 const char *name); 144 void silcpurple_chat_leave(PurpleConnection *gc, int id); 145 int silcpurple_chat_send(PurpleConnection *gc, int id, const char *msg, PurpleMessageFlags flags); 146 void silcpurple_chat_set_topic(PurpleConnection *gc, int id, const char *topic); 147 PurpleRoomlist *silcpurple_roomlist_get_list(PurpleConnection *gc); 148 void silcpurple_roomlist_cancel(PurpleRoomlist *list); 149 void silcpurple_chat_chauth_show(SilcPurple sg, SilcChannelEntry channel, 150 SilcDList channel_pubkeys); 151 void silcpurple_parse_attrs(SilcDList attrs, char **moodstr, char **statusstr, 152 char **contactstr, char **langstr, char **devicestr, 153 char **tzstr, char **geostr); 154 void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img); 155 char *silcpurple_file2mime(const char *filename); 156 SilcDList silcpurple_image_message(const char *msg, SilcMessageFlags *mflags); 157 158 #ifdef _WIN32 159 typedef int uid_t; 160 161 struct passwd { 162 char *pw_name; /* user name */ 163 char *pw_passwd; /* user password */ 164 int pw_uid; /* user id */ 165 int pw_gid; /* group id */ 166 char *pw_gecos; /* real name */ 167 char *pw_dir; /* home directory */ 168 char *pw_shell; /* shell program */ 169 }; 170 171 struct passwd *getpwuid(int uid); 172 int getuid(void); 173 int geteuid(void); 174 #endif 175 176 #endif /* SILCPURPLE_H */ 177