forked from kitech/kitphone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mosipphone.h
204 lines (159 loc) · 5.45 KB
/
mosipphone.h
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
196
197
198
199
200
201
202
203
204
// mosipphone.h ---
//
// Author: liuguangzhao
// Copyright (C) 2007-2012 liuguangzhao@users.sf.net
// URL:
// Created: 2011-08-10 15:08:21 +0000
// Version: $Id: mosipphone.h 999 2011-09-17 14:25:17Z drswinghead $
//
#ifndef _MOSIPPHONE_H_
#define _MOSIPPHONE_H_
#include <QtCore>
#include <QtNetwork>
#include <QtGui>
#include <QtSql>
#include "boost/signals2.hpp"
#include "boost/smart_ptr.hpp"
#include "intermessage.h"
class SipAccount;
class AsyncDatabase;
class ContactModel;
class CallHistoryModel;
class SqlRequest;
class SipEngine;
class SkycitEngine;
class BoostBridge;
class WebSocketClient2;
class Preferences;
namespace Ui {
class MosipPhone;
};
// 还要让它处理异步来自主界面线程的sip调用
// class PJSipEventThread : public QThread
// {
// Q_OBJECT;
// public:
// explicit PJSipEventThread(QObject *parent = 0);
// virtual ~PJSipEventThread();
// void run();
// void dump_info(pj_thread_t *thread);
// private:
// bool quit_loop;
// };
class MosipPhone : public QWidget
{
Q_OBJECT;
public:
explicit MosipPhone(QMainWindow *win, QWidget *parent = 0);
virtual ~MosipPhone();
public slots:
// ui
void main_ui_draw_complete();
void init_client_ui_element();
void onManageSipAccounts();
void onShowPreferences();
void onRegisterAccount(QString display_name, QString user_name, const QString serv_addr, bool reg);
void onRemoveAccount(QString user_name, const QString serv_addr);
bool setEngineEnable(int engine_index, bool enable);
// void onCallHangupButtonClicked();
void onSwitchCallStatePannel(bool calling);
void onCallSipNew();
void onHangupSipNew();
void onSipAnswered();
void onSipDisconnected();
void onRegisterState(const CmdRegState &cmd_rs);
void onCallState(const CmdCallState &cmd_cs);
void onCallMediaState(const CmdCallMediaState &cmd_cms);
void onCodecList(const CmdCodecList &cmd_cl);
void onSelectedUserAccountChanged(int idx);
void onDigitButtonClicked();
void onon_mosip_engine_error(int eno);
void onon_mosip_engine_started();
void onon_skycit_engine_started();
void onon_skycit_engine_error(int eno);
void onon_ws_client_connected(QString rpath);
void onon_ws_client_disconnected();
void onon_ws_client_error();
void onon_ws_client_message(QByteArray msg);
void onDatabaseConnected();
// database exec callbacks
void onSqlExecuteDone(const QList<QSqlRecord> & results, int reqno, bool eret,
const QString &estr, const QVariant &eval);
void onAddContact();
void onModifyContact();
void onAddGroup();
void onShowDialPanel();
void onShowLogPanel();
void onDynamicSetVisible(QWidget *w, bool visible);
void onDynamicSetVisible();
void customAddContactButtonMenu();
void initContactViewContextMenu();
void onShowContactViewMenu(const QPoint &pos);
bool onAddContactDone(boost::shared_ptr<SqlRequest> req);
bool onModifyContactDone(boost::shared_ptr<SqlRequest> req);
bool onAddGroupDone(boost::shared_ptr<SqlRequest> req);
bool onAddCallHistoryDone(boost::shared_ptr<SqlRequest> req);
bool onGetAllContactsDone(boost::shared_ptr<SqlRequest> req);
bool onGetAllGroupsDone(boost::shared_ptr<SqlRequest> req);
bool onGetAllHistoryDone(boost::shared_ptr<SqlRequest> req);
bool onGetAllAccountsDone(boost::shared_ptr<SqlRequest> req);
void onAccountAdded(SipAccount &acc);
void onAccountRemoved(SipAccount &acc);
// impl
bool savePreferences(Preferences *prefs);
bool loadPreferences(Preferences *prefs);
bool onSavePreferencesDone(boost::shared_ptr<SqlRequest> req);
bool onLoadPreferencesDone(boost::shared_ptr<SqlRequest> req);
bool onPostLoadPreferencesDone();
void log_output(int type, const QString &log);
public:
enum LOGTYPE {
LT_USER = 0,
LT_DEBUG = 1
};
private:
// pjsua_acc_id _create_sip_account(QString user_name, QString serv_adder);
// QString _get_sip_from_domain();
// int _find_account_from_pjacc(QString user_name, const QString serv_addr);
QString _reformat_call_phone_number(const QString &user_phone_number);
QString _get_input_phone_number();
bool _update_current_account_status(int acc_id);
bool process_ctrl_message(const std::string &msg);
protected:
bool first_paint_event;
virtual void paintEvent ( QPaintEvent * event );
virtual void showEvent ( QShowEvent * event );
signals:
void sig_test_q2b_rt();
private:
///////////////////////
QMainWindow *main_win;
QWidget *mdyn_widget;
bool mdyn_visible;
QGraphicsOpacityEffect *mdyn_oe;
// QStatusBar *m_status_bar;
int m_dialpanel_layout_index;
QLayoutItem *m_dialpanel_layout_item;
int m_call_state_layout_index;
QLayoutItem *m_call_state_layout_item;
int m_log_list_layout_index;
QLayoutItem *m_log_list_layout_item;
QMenu *m_contact_view_ctx_menu;
// AsyncDatabase *m_adb;
boost::shared_ptr<AsyncDatabase> m_adb;
//// sql reqno <---> sql reqclass
QHash<int, boost::shared_ptr<SqlRequest> > mRequests;
ContactModel *m_contact_model;
CallHistoryModel *m_call_history_model;
int m_acc_id;
int m_call_id;
std::vector<std::string> sip_codecs;
SipEngine *mse;
SkycitEngine *msce;
BoostBridge *mbb;
WebSocketClient2 *wsc2;
QVector<std::string> cmds_queue_before_connected;
private:
Ui::MosipPhone *uiw;
};
#endif /* _MOSIPPHONE_H_ */