about.c: cosmetix
[k8lowj.git] / src / account.h
blob523da04a735302a51a505ed119028db60dcc6038
1 /* logjam - a GTK client for LiveJournal.
2 * Copyright (C) 2000-2003 Gaal Yahas <gaal@forum2.org>
4 * vim: tabstop=4 shiftwidth=4 noexpandtab :
5 */
7 #ifndef _jam_account_
8 #define _jam_account_
10 #include <glib.h>
11 #include <glib-object.h>
12 #include "liblj/livejournal.h"
13 #include <libxml/tree.h>
15 #include "network.h" /* need netcontext struct. */
17 #define JAM_TYPE_ACCOUNT (jam_account_get_type())
18 #define JAM_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JAM_TYPE_ACCOUNT, JamAccount))
19 #define JAM_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), JAM_TYPE_ACCOUNT, JamAccountClass))
21 typedef struct _JamAccountClass JamAccountClass;
22 typedef struct _JamAccount JamAccount;
24 #define JAM_TYPE_HOST (jam_host_get_type())
25 #define JAM_HOST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JAM_TYPE_HOST, JamHost))
26 #define JAM_HOST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), JAM_TYPE_HOST, JamHostClass))
28 typedef struct _JamHostClass JamHostClass;
29 typedef struct _JamHost JamHost;
31 struct _JamAccount {
32 GObject obj;
34 JamHost *host;
36 gboolean remember_user;
37 gboolean remember_password;
40 struct _JamAccountClass {
41 GObjectClass parent_class;
43 void (*set_username)(JamAccount *acc, const char *username);
44 const gchar* (*get_username)(JamAccount *acc);
45 void (*set_password)(JamAccount *acc, const char *password);
46 const gchar* (*get_password)(JamAccount *acc);
49 typedef struct _JamAccountLJ JamAccountLJ;
51 #define JAM_TYPE_ACCOUNT_LJ (jam_account_lj_get_type())
52 #define JAM_ACCOUNT_LJ(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JAM_TYPE_ACCOUNT_LJ, JamAccountLJ))
53 #define JAM_ACCOUNT_IS_LJ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JAM_TYPE_ACCOUNT_LJ))
55 struct _JamAccountLJ {
56 JamAccount account;
57 LJUser *user;
58 guint32 cfmask;
59 time_t lastupdate;
62 #ifdef blogger_punted_for_this_release
63 typedef struct _JamAccountBlogger JamAccountBlogger;
65 #define JAM_TYPE_ACCOUNT_BLOGGER (jam_account_blogger_get_type())
66 #define JAM_ACCOUNT_BLOGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JAM_TYPE_ACCOUNT_BLOGGER, JamAccountBlogger))
67 #define JAM_ACCOUNT_IS_BLOGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JAM_TYPE_ACCOUNT_BLOGGER))
69 struct _JamAccountBlogger {
70 JamAccount account;
71 char *username, *password;
73 #endif /* blogger_punted_for_this_release */
75 typedef struct _JamHostLJ JamHostLJ;
76 #define JAM_TYPE_HOST_LJ (jam_host_lj_get_type())
77 #define JAM_HOST_LJ(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JAM_TYPE_HOST_LJ, JamHostLJ))
78 #define JAM_HOST_IS_LJ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JAM_TYPE_HOST_LJ))
80 #ifdef blogger_punted_for_this_release
81 typedef struct _JamHostBlogger JamHostBlogger;
82 #define JAM_TYPE_HOST_BLOGGER (jam_host_blogger_get_type())
83 #define JAM_HOST_BLOGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), JAM_TYPE_HOST_BLOGGER, JamHostBlogger))
84 #define JAM_HOST_IS_BLOGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JAM_TYPE_HOST_BLOGGER))
85 #endif /* blogger_punted_for_this_release */
87 struct _JamHost {
88 GObject obj;
90 char *name;
91 GSList *accounts;
92 JamAccount *lastaccount;
95 struct _JamHostClass {
96 GObjectClass parent_class;
98 const char* (*get_stock_icon)(void);
99 void (*save_xml)(JamHost *host, xmlNodePtr servernode);
100 gboolean (*load_xml)(JamHost *host, xmlDocPtr doc, xmlNodePtr servernode);
101 JamAccount* (*make_account)(JamHost *host, const char *username);
103 gboolean (*do_post)(JamHost *host, NetContext *ctx, void *doc, GError **err);
104 gboolean (*do_edit)(JamHost *host, NetContext *ctx, void *doc, GError **err);
105 gboolean (*do_delete)(JamHost *host, NetContext *ctx, void *doc, GError **err);
108 void jam_account_logjam_init(void);
109 GType jam_account_get_type(void);
110 JamAccount* jam_account_from_xml(xmlDocPtr doc, xmlNodePtr node, JamHost *host);
111 JamAccount* jam_account_make(LJUser *u);
112 JamAccount* jam_account_new_from_names(const gchar *username, const gchar *servername);
113 gchar* jam_account_id_strdup_from_names(const gchar *username, const gchar *servername);
114 gchar* jam_account_id_strdup(JamAccount *acc);
115 JamAccount* jam_account_lookup(gchar *id);
116 JamAccount* jam_account_lookup_by_user(LJUser *u);
118 void jam_account_connect(JamAccount *acc, gboolean connect);
119 void jam_account_connect_all(gboolean connect);
121 const gchar* jam_account_get_username (JamAccount *acc);
122 const gchar* jam_account_get_password (JamAccount *acc);
123 JamHost* jam_account_get_host (JamAccount *acc);
125 void jam_account_set_username(JamAccount *acc, const char *username);
126 void jam_account_set_password(JamAccount *acc, const char *password);
127 void jam_account_set_remember (JamAccount *acc, gboolean u, gboolean p);
128 void jam_account_get_remember (JamAccount *acc, gboolean *u, gboolean *p);
129 gboolean jam_account_get_remember_password(JamAccount *acc);
131 gboolean jam_account_write(JamAccount *account, GError **err);
133 GType jam_account_lj_get_type(void);
134 JamAccount* jam_account_lj_new(LJServer *server, const char *username);
135 JamAccount* jam_account_lj_from_xml(xmlDocPtr doc, xmlNodePtr node, JamHostLJ *host);
136 void jam_account_lj_write(JamAccountLJ *account, xmlNodePtr node);
138 LJUser* jam_account_lj_get_user (JamAccountLJ *acc);
139 LJServer* jam_account_lj_get_server(JamAccountLJ *acc);
140 guint32 jam_account_lj_get_cfmask(JamAccountLJ *acc);
141 void jam_account_lj_set_cfmask(JamAccountLJ *acc, guint32 mask);
142 gboolean jam_account_lj_get_checkfriends(JamAccount *acc);
144 #ifdef blogger_punted_for_this_release
145 GType jam_account_blogger_get_type(void);
146 JamAccount* jam_account_blogger_new(const char *username);
147 JamAccount* jam_account_blogger_from_xml(xmlDocPtr doc, xmlNodePtr node, JamHostBlogger *host);
148 #endif /* blogger_punted_for_this_release */
151 typedef enum {
152 JAM_HOST_SUBMITTING_ENTRY,
153 JAM_HOST_SAVING_CHANGES,
154 JAM_HOST_DELETING_ENTRY,
155 } JamHostActionTitle;
157 GType jam_host_get_type(void);
158 const char* jam_host_get_stock_icon(JamHost *host);
160 JamAccount* jam_host_get_account_by_username(JamHost *host, const char *username, gboolean create);
161 void jam_host_add_account(JamHost *host, JamAccount *acc);
163 JamHost* jam_host_from_xml(xmlDocPtr doc, xmlNodePtr node, void *data);
164 gboolean jam_host_write(JamHost *host, GError **err);
166 gboolean jam_host_do_post(JamHost *host, NetContext *ctx, void *doc, GError **err);
167 gboolean jam_host_do_edit(JamHost *host, NetContext *ctx, void *doc, GError **err);
168 gboolean jam_host_do_delete(JamHost *host, NetContext *ctx, void *doc, GError **err);
171 LJServer* jam_host_lj_get_server(JamHostLJ *host);
173 JamHostLJ* jam_host_lj_new(LJServer *s);
174 GType jam_host_lj_get_type(void);
177 #ifdef blogger_punted_for_this_release
178 char* jam_host_blogger_get_rpcurl(JamHostBlogger *host);
179 void jam_host_blogger_set_rpcurl(JamHostBlogger *host, const char* url);
181 JamHostBlogger* jam_host_blogger_new(void);
182 GType jam_host_blogger_get_type(void);
183 #endif /* blogger_punted_for_this_release */
185 #endif /* _jam_account_ */