# Servers and Users

## Name

Servers and Users -- Data structures representing LiveJournal servers and users.

## Synopsis

    struct      LJServer;
    struct      LJUser;
    enum        LJAuthScheme;
    LJServer*   lj_server_new                   (const char *url);
    int         lj_server_get_last_cached_moodid
                                                (LJServer *server);
    #define     lj_server_unicode               (s)
    LJUser*     lj_user_new                     (LJServer *server);
    gint        lj_user_compare                 (gconstpointer a,
                                                 gconstpointer b);
    #define     lj_mood_new                     ()
    #define     lj_mood_id_from_name            (server, name)
    #define     lj_mood_name_from_id            (server, id)
    #define     lj_mood_compare
    #define     lj_friendgroup_new              ()
    #define     lj_friendgroup_from_id          (user, id)
    #define     lj_friend_group_free
    typedef     LJWebMenuItem;
    #define     lj_webmenuitem_new              ()
    void        lj_webmenu_free                 (GSList *menu);

## Description

## Details

### struct LJServer

    struct LJServer {

    	char *url;

    	GSList *moods;

    	int protocolversion;
    	LJAuthScheme authscheme;
    };

A LiveJournal server.

char *`url` | url to the LiveJournal installation on the server.
GSList *`moods` | a list of LJMood.
int `protocolversion` | protocol version to use on the server.
LJAuthScheme `authscheme` |

### struct LJUser

    struct LJUser {

    	LJServer *server;

    	char *username;
    	char *password;
    	char *fullname;

    	gboolean checkfriends;

    	GSList *pickws;
    	GSList *friendgroups;
    	GSList *usejournals;
    	GSList *webmenu;
    };

A LiveJournal user. Fields other than server, username, and password are provided by the server in the login mode.

LJServer *`server` | the LJServer this user is on.
char *`username` | the username.
char *`password` | the password.
char *`fullname` | the full name for this user.
gboolean `checkfriends` |
GSList *`pickws` | a list of strings comprising the picture keywords for this user.
GSList *`friendgroups` | a list of LJFriendGroup.
GSList *`usejournals` | a list of journal usernames this user can post in.
GSList *`webmenu` | a list of LJWebMenuItem.

### enum LJAuthScheme

    typedef enum {
    	LJ_AUTH_SCHEME_UNKNOWN,
    	LJ_AUTH_SCHEME_NONE, /* we use md5 passwords by default.
    	                        they're replayable, but at least you're not sending
    	                        in plaintext. */
    	LJ_AUTH_SCHEME_C0, /* challenge/response.
    	                      http://www.livejournal.com/~lj_dev/599743.html. */
    	LJ_AUTH_SCHEME_OTHER /* for authschemes we don't know about yet. */
    } LJAuthScheme;

### lj_server_new ()

    LJServer*   lj_server_new                   (const char *url);

Create a new LJServer.

url : | url to the LiveJournal installation on the server.
Returns : | a new LJServer.

### lj_server_get_last_cached_moodid ()

    int         lj_server_get_last_cached_moodid
                                                (LJServer *server);

Get the last moodid in the mood list of server. Used in the login mode to only retrieve new moodids.

server : | an LJServer.
Returns : | integer moodid.

### lj_server_unicode()

    #define lj_server_unicode(s) ((s)->protocolversion > 0)

s : |

### lj_user_new ()

    LJUser*     lj_user_new                     (LJServer *server);

server : |
Returns : |

### lj_user_compare ()

    gint        lj_user_compare                 (gconstpointer a,
                                                 gconstpointer b);

a : |
b : |
Returns : |

### lj_mood_new()

    #define lj_mood_new() g_new0(LJMood, 1)

### lj_mood_id_from_name()

    #define lj_mood_id_from_name(server, name) _lj_nid_by_name(server->moods, name)

server : |
name : |

### lj_mood_name_from_id()

    #define lj_mood_name_from_id(server, id) _lj_nid_by_id(server->moods, id)

server : |
id : |

### lj_mood_compare

    #define lj_mood_compare _lj_nid_compare_alpha

### lj_friendgroup_new()

    #define lj_friendgroup_new() g_new0(LJFriendGroup, 1)

### lj_friendgroup_from_id()

    #define lj_friendgroup_from_id(user, id) _lj_nid_by_id(user->friendgroups, id)

user : |
id : |

### lj_friend_group_free

    #define lj_friend_group_free _lj_nid_free

### LJWebMenuItem

    typedef struct {
    	char *text;
    	char *url;
    	GSList *subitems;
    } LJWebMenuItem;

### lj_webmenuitem_new()

    #define lj_webmenuitem_new() g_new0(LJWebMenuItem, 1)

### lj_webmenu_free ()

    void        lj_webmenu_free                 (GSList *menu);

menu : |