| 1 | /* |
|---|
| 2 | * WengoPhone, a voice over Internet phone |
|---|
| 3 | * Copyright (C) 2004-2007 Wengo |
|---|
| 4 | * |
|---|
| 5 | * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | * it under the terms of the GNU General Public License as published by |
|---|
| 7 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | * (at your option) any later version. |
|---|
| 9 | * |
|---|
| 10 | * This program is distributed in the hope that it will be useful, |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | * GNU General Public License for more details. |
|---|
| 14 | * |
|---|
| 15 | * You should have received a copy of the GNU General Public License |
|---|
| 16 | * along with this program; if not, write to the Free Software |
|---|
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #include "QtBrowserWidget.h" |
|---|
| 21 | #include "QtWengoPhone.h" |
|---|
| 22 | |
|---|
| 23 | #include <control/profile/CUserProfile.h> |
|---|
| 24 | #include <control/profile/CUserProfileHandler.h> |
|---|
| 25 | #include <control/CWengoPhone.h> |
|---|
| 26 | |
|---|
| 27 | #include <model/account/wengo/WengoAccount.h> |
|---|
| 28 | #include <model/profile/UserProfile.h> |
|---|
| 29 | #include <model/config/Config.h> |
|---|
| 30 | #include <model/config/ConfigManager.h> |
|---|
| 31 | #include <model/network/NetworkProxyDiscovery.h> |
|---|
| 32 | |
|---|
| 33 | #include <qtutil/SafeConnect.h> |
|---|
| 34 | #include <util/Logger.h> |
|---|
| 35 | #include <util/SafeDelete.h> |
|---|
| 36 | #include <util/Path.h> |
|---|
| 37 | #include <WengoPhoneBuildId.h> |
|---|
| 38 | |
|---|
| 39 | #include <QtGui/QtGui> |
|---|
| 40 | #include <QtWebKit/QWebView> |
|---|
| 41 | #include <QtCore/QtCore> |
|---|
| 42 | |
|---|
| 43 | const QString ANCHOR_DIALPAD = "qutecom_dial"; |
|---|
| 44 | const QString ANCHOR_CONTACTLIST = "qutecom_phonebook"; |
|---|
| 45 | const QString ANCHOR_ADDCONTACT = "qutecom_addcontact"; |
|---|
| 46 | const QString ANCHOR_SECRET_PERMANENT = "qutecom_secret_permanent"; |
|---|
| 47 | const QString ANCHOR_SFR_FR = "qutecom_sfr_fr"; |
|---|
| 48 | const QString ANCHOR_MON_COMPTE = "qutecom_mon_compte"; |
|---|
| 49 | const QString ANCHOR_REPONDEUR = "qutecom_repondeur"; |
|---|
| 50 | |
|---|
| 51 | QtBrowserWidget::QtBrowserWidget(QtWengoPhone & qtWengoPhone) |
|---|
| 52 | : _qtWengoPhone(qtWengoPhone) { |
|---|
| 53 | |
|---|
| 54 | Config & config = ConfigManager::getInstance().getCurrentConfig(); |
|---|
| 55 | base_path = QString::fromStdString(config.getResourcesDir()); |
|---|
| 56 | #if defined (OS_WINDOWS) |
|---|
| 57 | base_path = base_path.replace("\\","/"); |
|---|
| 58 | #endif |
|---|
| 59 | |
|---|
| 60 | _qtBrowser = new QWebView(_qtWengoPhone.getWidget()); |
|---|
| 61 | _qtBrowser ->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff); |
|---|
| 62 | _qtBrowser ->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); |
|---|
| 63 | |
|---|
| 64 | SAFE_CONNECT(&_qtWengoPhone, SIGNAL(userProfileDeleted()), SLOT(slotUserProfileDeleted())); |
|---|
| 65 | |
|---|
| 66 | _qtBrowser ->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); |
|---|
| 67 | connect(_qtBrowser,SIGNAL(linkClicked(const QUrl &)),this,SLOT(linkClicked_slot(const QUrl &))); |
|---|
| 68 | |
|---|
| 69 | loadDefaultURL(); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | QtBrowserWidget::~QtBrowserWidget() |
|---|
| 73 | { |
|---|
| 74 | OWSAFE_DELETE(_qtBrowser); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | QWidget * QtBrowserWidget::getWidget() const |
|---|
| 78 | { |
|---|
| 79 | return _qtBrowser; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | void QtBrowserWidget::slotUserProfileDeleted() |
|---|
| 83 | { |
|---|
| 84 | _qtBrowser->load(QUrl(base_path + "/webpages/windows/sip.html")); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | void QtBrowserWidget::loadDefaultURL() |
|---|
| 88 | { |
|---|
| 89 | _qtBrowser->load(QUrl(base_path + "/webpages/windows/loading.html")); |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | void QtBrowserWidget::loadAccountURL() |
|---|
| 93 | { |
|---|
| 94 | _qtBrowser->load(QUrl(base_path + "/webpages/windows/sip.html")); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | void QtBrowserWidget::linkClicked_slot(const QUrl & url) |
|---|
| 98 | { |
|---|
| 99 | QString surl = url.toString(); |
|---|
| 100 | |
|---|
| 101 | if(surl.contains(ANCHOR_CONTACTLIST)) |
|---|
| 102 | { |
|---|
| 103 | //QStringList list = surl.split(ANCHOR_CONTACTLIST); |
|---|
| 104 | //if(list.count() == 2) |
|---|
| 105 | //{ |
|---|
| 106 | openwengo_phonebook_signal(); |
|---|
| 107 | //} |
|---|
| 108 | } |
|---|
| 109 | /*else if(surl.contains(ANCHOR_HISTORY)) |
|---|
| 110 | { |
|---|
| 111 | QStringList list = surl.split(ANCHOR_CONTACTLIST); |
|---|
| 112 | if(list.count() == 2) |
|---|
| 113 | { |
|---|
| 114 | openwengo_log_signal(); |
|---|
| 115 | } |
|---|
| 116 | } |
|---|
| 117 | else if(surl.contains(ANCHOR_CONFIGURATION)) |
|---|
| 118 | { |
|---|
| 119 | QStringList list = surl.split(ANCHOR_CONTACTLIST); |
|---|
| 120 | if(list.count() == 2) |
|---|
| 121 | { |
|---|
| 122 | openwengo_configuration_signal(); |
|---|
| 123 | } |
|---|
| 124 | }*/ |
|---|
| 125 | else if(surl.contains(ANCHOR_DIALPAD)) |
|---|
| 126 | { |
|---|
| 127 | //QStringList list = surl.split(ANCHOR_CONTACTLIST); |
|---|
| 128 | //if(list.count() == 2) |
|---|
| 129 | //{ |
|---|
| 130 | openwengo_dial_signal(); |
|---|
| 131 | //} |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | else if(surl.contains(ANCHOR_ADDCONTACT)) |
|---|
| 135 | { |
|---|
| 136 | //QStringList list = surl.split(ANCHOR_CONTACTLIST); |
|---|
| 137 | //if(list.count() == 2) |
|---|
| 138 | //{ |
|---|
| 139 | openwengo_addcontact_signal(); |
|---|
| 140 | //} |
|---|
| 141 | } |
|---|
| 142 | /*else if(surl.contains(ANCHOR_SELFCARE)) |
|---|
| 143 | { |
|---|
| 144 | QStringList list = surl.split(ANCHOR_CONTACTLIST); |
|---|
| 145 | if(list.count() == 2) |
|---|
| 146 | { |
|---|
| 147 | openwengo_selfcare_signal(); |
|---|
| 148 | } |
|---|
| 149 | } |
|---|
| 150 | else if(surl.contains(ANCHOR_FORUM)) |
|---|
| 151 | { |
|---|
| 152 | QStringList list = surl.split(ANCHOR_CONTACTLIST); |
|---|
| 153 | if(list.count() == 2) |
|---|
| 154 | { |
|---|
| 155 | openwengo_forum_signal(); |
|---|
| 156 | } |
|---|
| 157 | } |
|---|
| 158 | else if(surl.contains(ANCHOR_SHOWSMARTDIRECTORY)) |
|---|
| 159 | { |
|---|
| 160 | //QStringList list = surl.split(ANCHOR_CONTACTLIST); |
|---|
| 161 | //if(list.count() == 2) |
|---|
| 162 | //{ |
|---|
| 163 | openwengo_smartdirectory_signal(); |
|---|
| 164 | //} |
|---|
| 165 | }*/ |
|---|
| 166 | } |
|---|