File: livejournal.h

package info (click to toggle)
sim 0.9.5~svn20080806-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 18,108 kB
  • ctags: 11,570
  • sloc: cpp: 119,605; sh: 9,986; ansic: 3,312; perl: 2,752; lex: 1,533; makefile: 839; xml: 206; python: 56
file content (195 lines) | stat: -rw-r--r-- 5,946 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/***************************************************************************
                          livejournal.h  -  description
                             -------------------
    begin                : Sun Mar 17 2002
    copyright            : (C) 2002 by Vladimir Shutoff
    email                : vovan@shutoff.ru
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _LIVEJOURNAL_H
#define _LIVEJOURNAL_H

#include "buffer.h"
#include "socket.h"
#include "fetch.h"

const unsigned long JournalCmdBase			= 0x00070000;
const unsigned long MessageJournal			= JournalCmdBase;
const unsigned long MessageUpdated			= JournalCmdBase + 1;
const unsigned long CmdDeleteJournalMessage	= JournalCmdBase + 2;
const unsigned long CmdMenuWeb				= JournalCmdBase + 3;
const unsigned long MenuWeb					= JournalCmdBase + 0x10;

const unsigned LIVEJOURNAL_SIGN	= 5;

const unsigned COMMENT_ENABLE	= 0;
const unsigned COMMENT_NO_MAIL	= 1;
const unsigned COMMENT_DISABLE	= 2;

struct LiveJournalUserData : public SIM::clientData
{
    SIM::Data	User;
    SIM::Data	Shared;
    SIM::Data	bChecked;
};

struct JournalMessageData
{
    SIM::Data	Subject;
    SIM::Data	Private;
    SIM::Data	Time;
    SIM::Data	ID;
    SIM::Data	OldID;
    SIM::Data	Mood;
    SIM::Data	Comments;
};

class JournalMessage : public SIM::Message
{
public:
    JournalMessage(Buffer *cfg = NULL);
    ~JournalMessage();
    virtual QCString save();
    PROP_UTF8(Subject);
    PROP_ULONG(Private);
    PROP_ULONG(Time);
    PROP_ULONG(ID);
    PROP_ULONG(OldID);
    PROP_ULONG(Mood);
    PROP_ULONG(Comments);
protected:
    QString presentation();
    JournalMessageData data;
};

class CorePlugin;

class LiveJournalPlugin : public SIM::Plugin
{
public:
    LiveJournalPlugin(unsigned);
    virtual ~LiveJournalPlugin();
    static CorePlugin *core;
    static unsigned MenuCount;
protected:
    SIM::Protocol *m_protocol;
};

class LiveJournalProtocol : public SIM::Protocol
{
public:
    LiveJournalProtocol(SIM::Plugin *plugin);
    ~LiveJournalProtocol();
    SIM::Client	*createClient(Buffer *cfg);
    const SIM::CommandDef *description();
    const SIM::CommandDef *statusList();
    const SIM::DataDef *userDataDef();
};

struct LiveJournalClientData
{
    SIM::Data	Server;
    SIM::Data	URL;
    SIM::Data	Port;
    SIM::Data	Interval;
    SIM::Data	Mood;
    SIM::Data	Moods;
    SIM::Data	Menu;
    SIM::Data	MenuUrl;
    SIM::Data	FastServer;
    SIM::Data	UseFormatting;
    SIM::Data	UseSignature;
    SIM::Data	Signature;
    SIM::Data	LastUpdate;
    LiveJournalUserData	owner;
};

class LiveJournalClient;

class LiveJournalRequest
{
public:
    LiveJournalRequest(LiveJournalClient *client, const char *mode);
    virtual ~LiveJournalRequest();
    void addParam(const QString &key, const QString &value);
    void result(Buffer*);
    virtual void result(const QString &key, const QString &value) = 0;
protected:
    LiveJournalClient *m_client;
    Buffer *m_buffer;
    bool getLine(Buffer *b, QCString &line);
    friend class LiveJournalClient;
};

class QTimer;

class LiveJournalClient : public SIM::TCPClient, public FetchClient
{
    Q_OBJECT
public:
    LiveJournalClient(SIM::Protocol*, Buffer *cfg);
    ~LiveJournalClient();
    PROP_STR(Server);
    PROP_STR(URL);
    PROP_USHORT(Port);
    PROP_ULONG(Interval);
    PROP_STRLIST(Mood);
    PROP_ULONG(Moods);
    PROP_STRLIST(Menu);
    PROP_STRLIST(MenuUrl);
    PROP_BOOL(FastServer);
    PROP_BOOL(UseFormatting);
    PROP_BOOL(UseSignature);
    PROP_UTF8(Signature);
    PROP_STR(LastUpdate);
    QString getSignatureText();
    void auth_fail(const QString &err);
    void auth_ok();
    LiveJournalUserData	*findContact(const QString &user, SIM::Contact *&contact, bool bCreate=true, bool bJoin=true);
    QTimer  *m_timer;
    virtual bool error_state(const QString &err, unsigned code);
    bool add(const QString &name);
    LiveJournalUserData* toLiveJournalUserData(SIM::clientData * data); // More safely type conversion from generic SIM::clientData into LiveJournalUserData
public slots:
    void timeout();
    void send();
    void messageUpdated();
protected:
    virtual bool done(unsigned code, Buffer &data, const QString &headers);
    virtual QCString getConfig();
    virtual QString name();
    virtual QString dataName(void*);
    virtual QWidget	*setupWnd();
    virtual bool isMyData(SIM::clientData*&, SIM::Contact*&);
    virtual bool createData(SIM::clientData*&, SIM::Contact*);
    virtual void setupContact(SIM::Contact*, void *data);
    virtual bool send(SIM::Message*, void *data);
    virtual bool canSend(unsigned type, void *data);
    virtual void setStatus(unsigned status);
    virtual void socketConnect();
    virtual void disconnected();
    virtual void packet_ready();
    virtual bool processEvent(SIM::Event *e);
    virtual void contactInfo(void*, unsigned long &curStatus, unsigned&, QString &statusIcon, QString *icons);
    QWidget *searchWindow(QWidget *parent);
    SIM::CommandDef *configWindows();
    QWidget *configWindow(QWidget *parent, unsigned id);
    void statusChanged();
    std::list<LiveJournalRequest*> m_requests;
    LiveJournalRequest		  *m_request;
    LiveJournalClientData	data;
    friend class LiveJournalCfg;
    friend class LiveJournalRequest;
};

#endif