Diffstat (limited to 'noncore/net/linphone/qlinphone.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/linphone/qlinphone.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/linphone/qlinphone.cpp b/noncore/net/linphone/qlinphone.cpp index 3cc2ebc..ba4ee5f 100644 --- a/noncore/net/linphone/qlinphone.cpp +++ b/noncore/net/linphone/qlinphone.cpp | |||
@@ -19,192 +19,192 @@ | |||
19 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | #include <qslider.h> | 22 | #include <qslider.h> |
23 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <linphonecore.h> | 28 | #include <linphonecore.h> |
29 | 29 | ||
30 | extern "C" { | 30 | extern "C" { |
31 | static void stub(LinphoneCore*lc, char*msg) {} | 31 | static void stub(LinphoneCore*lc, char*msg) {} |
32 | 32 | ||
33 | static void qt_show(LinphoneCore *lc) { | 33 | static void qt_show(LinphoneCore *lc) { |
34 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; | 34 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; |
35 | w->pushGuiTask(new ShowTask(w)); | 35 | w->pushGuiTask(new ShowTask(w)); |
36 | } | 36 | } |
37 | 37 | ||
38 | static void qt_inv_recv(LinphoneCore *lc, char *from) { | 38 | static void qt_inv_recv(LinphoneCore *lc, char *from) { |
39 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; | 39 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; |
40 | QString tmp(from); | 40 | QString tmp(from); |
41 | w->pushGuiTask(new InviteReceivedTask(w,tmp)); | 41 | w->pushGuiTask(new InviteReceivedTask(w,tmp)); |
42 | } | 42 | } |
43 | 43 | ||
44 | static void qt_display_status(LinphoneCore *lc, char *status) { | 44 | static void qt_display_status(LinphoneCore *lc, char *status) { |
45 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; | 45 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; |
46 | QString tmp(status); | 46 | QString tmp(status); |
47 | w->pushGuiTask(new UpdateStatusBarTask(w,tmp)); | 47 | w->pushGuiTask(new UpdateStatusBarTask(w,tmp)); |
48 | } | 48 | } |
49 | static void qt_display_message(LinphoneCore *lc, char *message) { | 49 | static void qt_display_message(LinphoneCore *lc, char *message) { |
50 | QString qmsg(message); | 50 | QString qmsg(message); |
51 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; | 51 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; |
52 | w->pushGuiTask(new DisplayMessageTask(w,qmsg,DisplayMessageTask::Info)); | 52 | w->pushGuiTask(new DisplayMessageTask(w,qmsg,DisplayMessageTask::Info)); |
53 | } | 53 | } |
54 | static void qt_display_warning(LinphoneCore *lc, char *message) { | 54 | static void qt_display_warning(LinphoneCore *lc, char *message) { |
55 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; | 55 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; |
56 | QString qmsg(message); | 56 | QString qmsg(message); |
57 | w->pushGuiTask(new DisplayMessageTask(w,qmsg,DisplayMessageTask::Warn)); | 57 | w->pushGuiTask(new DisplayMessageTask(w,qmsg,DisplayMessageTask::Warn)); |
58 | } | 58 | } |
59 | static void qt_display_url(LinphoneCore *lc, char *message, char *url) { | 59 | static void qt_display_url(LinphoneCore *lc, char *message, char *url) { |
60 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; | 60 | QLinphoneMainWidget *w=(QLinphoneMainWidget*)lc->data; |
61 | QString qmsg=QString(message)+QString(url); | 61 | QString qmsg=QString(message)+QString(url); |
62 | w->pushGuiTask(new DisplayMessageTask(w,qmsg,DisplayMessageTask::Info)); | 62 | w->pushGuiTask(new DisplayMessageTask(w,qmsg,DisplayMessageTask::Info)); |
63 | } | 63 | } |
64 | static void qt_notify_recv(LinphoneCore *lc, const char *url, const char *status) { | 64 | static void qt_notify_recv(LinphoneCore *lc, const char *url, const char *status) { |
65 | } | 65 | } |
66 | 66 | ||
67 | LinphoneCoreVTable lcvtable={ | 67 | LinphoneCoreVTable lcvtable={ |
68 | show: | 68 | show: |
69 | qt_show, | 69 | qt_show, |
70 | inv_recv: | 70 | inv_recv: |
71 | qt_inv_recv, | 71 | qt_inv_recv, |
72 | bye_recv : | 72 | bye_recv : |
73 | stub, | 73 | stub, |
74 | notify_recv : | 74 | notify_recv : |
75 | qt_notify_recv, | 75 | qt_notify_recv, |
76 | display_status : | 76 | display_status : |
77 | qt_display_status, | 77 | qt_display_status, |
78 | display_message : | 78 | display_message : |
79 | qt_display_message, | 79 | qt_display_message, |
80 | display_warning : | 80 | display_warning : |
81 | qt_display_warning, | 81 | qt_display_warning, |
82 | display_url : | 82 | display_url : |
83 | qt_display_url, | 83 | qt_display_url, |
84 | display_question : | 84 | display_question : |
85 | stub | 85 | stub |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | } //extern "C" | 89 | } //extern "C" |
90 | 90 | ||
91 | void UpdateStatusBarTask::execute() { | 91 | void UpdateStatusBarTask::execute() { |
92 | static_cast<QLinphoneMainWidget*>(_w)->displayStatus(_msg); | 92 | static_cast<QLinphoneMainWidget*>(_w)->displayStatus(_msg); |
93 | } | 93 | } |
94 | 94 | ||
95 | void InviteReceivedTask::execute() { | 95 | void InviteReceivedTask::execute() { |
96 | static_cast<QLinphoneMainWidget*>(_w)->inviteReceived(_msg); | 96 | static_cast<QLinphoneMainWidget*>(_w)->inviteReceived(_msg); |
97 | } | 97 | } |
98 | 98 | ||
99 | void DisplayMessageTask::execute() { | 99 | void DisplayMessageTask::execute() { |
100 | switch(_msgtype) { | 100 | switch(_msgtype) { |
101 | case Info: | 101 | case Info: |
102 | QMessageBox::information(0,QObject::tr("Information"),_msg); | 102 | QMessageBox::information(0,QObject::tr("Information"),_msg); |
103 | break; | 103 | break; |
104 | case Warn: | 104 | case Warn: |
105 | QMessageBox::warning(0,QObject::tr("Warning"),_msg); | 105 | QMessageBox::warning(0,QObject::tr("Warning"),_msg); |
106 | break; | 106 | break; |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | QLinphoneMainWidget::QLinphoneMainWidget(QWidget* parent , const char* name , WFlags fl ) : | 110 | QLinphoneMainWidget::QLinphoneMainWidget(QWidget* parent , const char* name , WFlags fl ) : |
111 | _QLinphoneMainWidget( parent, name, fl ) { | 111 | _QLinphoneMainWidget( parent, name, fl ) { |
112 | 112 | ||
113 | readConfig(); | 113 | readConfig(); |
114 | createLinphoneCore(); | 114 | createLinphoneCore(); |
115 | connect( CheckBox1, SIGNAL( toggled( bool ) ), this, SLOT( slotHide( bool ) ) ); | 115 | connect( CheckBox1, SIGNAL( toggled(bool) ), this, SLOT( slotHide(bool) ) ); |
116 | CheckBox1->setChecked( true ); | 116 | CheckBox1->setChecked( true ); |
117 | } | 117 | } |
118 | 118 | ||
119 | QLinphoneMainWidget::~QLinphoneMainWidget() { | 119 | QLinphoneMainWidget::~QLinphoneMainWidget() { |
120 | linphone_core_destroy(_core); | 120 | linphone_core_destroy(_core); |
121 | writeConfig(); | 121 | writeConfig(); |
122 | } | 122 | } |
123 | 123 | ||
124 | void QLinphoneMainWidget::slotHide( bool show ) { | 124 | void QLinphoneMainWidget::slotHide( bool show ) { |
125 | if ( show ) { | 125 | if ( show ) { |
126 | TabWidget2->show(); | 126 | TabWidget2->show(); |
127 | } else { | 127 | } else { |
128 | TabWidget2->hide(); | 128 | TabWidget2->hide(); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | void QLinphoneMainWidget::callOrAccept() { | 132 | void QLinphoneMainWidget::callOrAccept() { |
133 | if (linphone_core_inc_invite_pending(_core)) { | 133 | if (linphone_core_inc_invite_pending(_core)) { |
134 | linphone_core_accept_dialog(_core,NULL); | 134 | linphone_core_accept_dialog(_core,NULL); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | QString url=sip_url->text(); | 137 | QString url=sip_url->text(); |
138 | linphone_core_invite(_core,(char*)url.ascii()); | 138 | linphone_core_invite(_core,(char*)url.ascii()); |
139 | } | 139 | } |
140 | void QLinphoneMainWidget::terminateCall() { | 140 | void QLinphoneMainWidget::terminateCall() { |
141 | linphone_core_terminate_dialog(_core,NULL); | 141 | linphone_core_terminate_dialog(_core,NULL); |
142 | } | 142 | } |
143 | 143 | ||
144 | void QLinphoneMainWidget::inviteReceived(QString &tmp) { | 144 | void QLinphoneMainWidget::inviteReceived(QString &tmp) { |
145 | sip_url->setText(tmp); | 145 | sip_url->setText(tmp); |
146 | } | 146 | } |
147 | 147 | ||
148 | void QLinphoneMainWidget::displayStatus(QString &msg) { | 148 | void QLinphoneMainWidget::displayStatus(QString &msg) { |
149 | status_bar->setText(msg); | 149 | status_bar->setText(msg); |
150 | } | 150 | } |
151 | 151 | ||
152 | void QLinphoneMainWidget::pushGuiTask(GuiTask* g) { | 152 | void QLinphoneMainWidget::pushGuiTask(GuiTask* g) { |
153 | _mutex.lock(); | 153 | _mutex.lock(); |
154 | _actionq.enqueue(g); | 154 | _actionq.enqueue(g); |
155 | _mutex.unlock(); | 155 | _mutex.unlock(); |
156 | printf("New action added to task list.\n"); | 156 | printf("New action added to task list.\n"); |
157 | } | 157 | } |
158 | 158 | ||
159 | void QLinphoneMainWidget::processGuiTasks() { | 159 | void QLinphoneMainWidget::processGuiTasks() { |
160 | GuiTask *g; | 160 | GuiTask *g; |
161 | _mutex.lock(); | 161 | _mutex.lock(); |
162 | while(!_actionq.isEmpty()) { | 162 | while(!_actionq.isEmpty()) { |
163 | g=_actionq.dequeue(); | 163 | g=_actionq.dequeue(); |
164 | printf("Executing action...\n"); | 164 | printf("Executing action...\n"); |
165 | g->execute(); | 165 | g->execute(); |
166 | delete g; | 166 | delete g; |
167 | } | 167 | } |
168 | _mutex.unlock(); | 168 | _mutex.unlock(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void QLinphoneMainWidget::timerEvent(QTimerEvent *t) { | 171 | void QLinphoneMainWidget::timerEvent(QTimerEvent *t) { |
172 | processGuiTasks(); | 172 | processGuiTasks(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void QLinphoneMainWidget::readConfig() { | 175 | void QLinphoneMainWidget::readConfig() { |
176 | Config cfg( "opie-phone" ); | 176 | Config cfg( "opie-phone" ); |
177 | cfg.setGroup( "audio" ); | 177 | cfg.setGroup( "audio" ); |
178 | SliderInput->setValue( cfg.readNumEntry( "rec_lev", 50 ) ); | 178 | SliderInput->setValue( cfg.readNumEntry( "rec_lev", 50 ) ); |
179 | SliderOutput->setValue( cfg.readNumEntry( "play_lev", 50 ) ); | 179 | SliderOutput->setValue( cfg.readNumEntry( "play_lev", 50 ) ); |
180 | } | 180 | } |
181 | 181 | ||
182 | void QLinphoneMainWidget::writeConfig() { | 182 | void QLinphoneMainWidget::writeConfig() { |
183 | Config cfg( "opie-phone" ); | 183 | Config cfg( "opie-phone" ); |
184 | cfg.setGroup( "audio" ); | 184 | cfg.setGroup( "audio" ); |
185 | cfg.writeEntry( "rec_lev", SliderInput->value() ); | 185 | cfg.writeEntry( "rec_lev", SliderInput->value() ); |
186 | cfg.writeEntry( "playlev", SliderOutput->value() ); | 186 | cfg.writeEntry( "playlev", SliderOutput->value() ); |
187 | } | 187 | } |
188 | 188 | ||
189 | void QLinphoneMainWidget::helpAbout() { | 189 | void QLinphoneMainWidget::helpAbout() { |
190 | QMessageBox::about(this,tr("About Linphone"),tr("QT version of linphone\nJuly 2003 - Made in old Europe.")); | 190 | QMessageBox::about(this,tr("About Linphone"),tr("QT version of linphone\nJuly 2003 - Made in old Europe.")); |
191 | } | 191 | } |
192 | 192 | ||
193 | void QLinphoneMainWidget::createLinphoneCore() { | 193 | void QLinphoneMainWidget::createLinphoneCore() { |
194 | if ( _core ) { | 194 | if ( _core ) { |
195 | linphone_core_destroy(_core); | 195 | linphone_core_destroy(_core); |
196 | } | 196 | } |
197 | 197 | ||
198 | gchar *home=getenv("HOME"); | 198 | gchar *home=getenv("HOME"); |
199 | gchar *suffix="/Settings/opie-phone.conf"; | 199 | gchar *suffix="/Settings/opie-phone.conf"; |
200 | if (home==0) | 200 | if (home==0) |
201 | home=strdup("/root"); | 201 | home=strdup("/root"); |
202 | gchar *config=new char[strlen(home)+strlen(suffix)+2]; | 202 | gchar *config=new char[strlen(home)+strlen(suffix)+2]; |
203 | sprintf(config,"%s/%s",home,suffix); | 203 | sprintf(config,"%s/%s",home,suffix); |
204 | /* tracing for osip */ | 204 | /* tracing for osip */ |
205 | TRACE_INITIALIZE((trace_level_t)5,stdout); | 205 | TRACE_INITIALIZE((trace_level_t)5,stdout); |
206 | _core=linphone_core_new(&lcvtable,config,(gpointer)this); | 206 | _core=linphone_core_new(&lcvtable,config,(gpointer)this); |
207 | delete [] config; | 207 | delete [] config; |
208 | startTimer(10); | 208 | startTimer(10); |
209 | } | 209 | } |
210 | 210 | ||