[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/protocols/wlm
From:       Tiago Salem Herrmann <tiagosh () gmail ! com>
Date:       2009-06-26 3:07:49
Message-ID: 1245985669.121734.20631.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 987423 by salem:

- add proxy support for wlm


 M  +311 -1    ui/wlmaccountpreferences.ui  
 M  +30 -0     ui/wlmeditaccountwidget.cpp  
 M  +31 -0     wlmaccount.cpp  
 M  +7 -0      wlmaccount.h  
 M  +1 -1      wlmlibmsn.cpp  
 M  +19 -1     wlmsocket.cpp  
 M  +2 -1      wlmsocket.h  


--- trunk/KDE/kdenetwork/kopete/protocols/wlm/ui/wlmaccountpreferences.ui \
#987422:987423 @@ -20,7 +20,7 @@
    <item>
     <widget class="QTabWidget" name="mainTabWidget">
      <property name="currentIndex">
-      <number>0</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="tab">
       <attribute name="title">
@@ -374,6 +374,156 @@
             </item>
            </layout>
           </item>
+          <item>
+           <widget class="QCheckBox" name="optionEnableProxy">
+            <property name="text">
+             <string>Enable Proxy</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="horizontalLayout_8" stretch="0,0,0,0">
+            <item>
+             <spacer name="horizontalSpacer">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+              <property name="sizeType">
+               <enum>QSizePolicy::Fixed</enum>
+              </property>
+              <property name="sizeHint" stdset="0">
+               <size>
+                <width>28</width>
+                <height>20</height>
+               </size>
+              </property>
+             </spacer>
+            </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_9">
+              <item>
+               <widget class="QLabel" name="m_labelProxyHost">
+                <property name="enabled">
+                 <bool>false</bool>
+                </property>
+                <property name="text">
+                 <string>Host /</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QLabel" name="m_labelProxyPort">
+                <property name="enabled">
+                 <bool>false</bool>
+                </property>
+                <property name="text">
+                 <string>port:</string>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+            <item>
+             <widget class="QLineEdit" name="m_proxyHost">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="cursorPosition">
+               <number>0</number>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QSpinBox" name="m_proxyPort">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="minimum">
+               <number>1</number>
+              </property>
+              <property name="maximum">
+               <number>65535</number>
+              </property>
+              <property name="value">
+               <number>8080</number>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="horizontalLayout_4">
+            <item>
+             <widget class="QRadioButton" name="m_radioProxyHttp">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="text">
+               <string>HTTP</string>
+              </property>
+              <property name="checked">
+               <bool>true</bool>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QRadioButton" name="m_radioProxySocks5">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="text">
+               <string>Socks5</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QLabel" name="m_labelProxyUsername">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="text">
+               <string>Username:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QLineEdit" name="m_proxyUsername">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QLabel" name="m_labelProxyPassword">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="text">
+               <string>Password:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QLineEdit" name="m_proxyPassword">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="echoMode">
+               <enum>QLineEdit::Password</enum>
+              </property>
+              <property name="alignment">
+               <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
          </layout>
         </widget>
        </item>
@@ -487,5 +637,165 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_labelProxyHost</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>75</x>
+     <y>161</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_labelProxyPort</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>115</x>
+     <y>161</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_proxyHost</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>365</x>
+     <y>161</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_proxyPort</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>630</x>
+     <y>161</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_radioProxyHttp</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>48</x>
+     <y>191</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_radioProxySocks5</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>115</x>
+     <y>191</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_proxyUsername</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>319</x>
+     <y>191</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_proxyPassword</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>571</x>
+     <y>191</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_labelProxyUsername</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>191</x>
+     <y>191</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>optionEnableProxy</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>m_labelProxyPassword</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>341</x>
+     <y>132</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>447</x>
+     <y>191</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
 </ui>
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/ui/wlmeditaccountwidget.cpp \
#987422:987423 @@ -20,6 +20,7 @@
 #include <QLineEdit>
 #include <QVBoxLayout>
 #include <QSet>
+#include <QNetworkProxy>
 
 #include <kdebug.h>
 #include <kmessagebox.h>
@@ -55,6 +56,19 @@
         m_preferencesWidget->m_serverName->setText( m_wlmAccount->serverName() );
         m_preferencesWidget->m_serverPort->setValue( m_wlmAccount->serverPort() );
 
+        if ( m_wlmAccount->isProxyEnabled() )
+            m_preferencesWidget->optionEnableProxy->setChecked( true );
+
+        m_preferencesWidget->m_proxyHost->setText( m_wlmAccount->proxyHost() );
+        m_preferencesWidget->m_proxyPort->setValue( m_wlmAccount->proxyPort() );
+        m_preferencesWidget->m_proxyUsername->setText( m_wlmAccount->proxyUsername() \
); +        m_preferencesWidget->m_proxyPassword->setText( \
m_wlmAccount->proxyPassword() ); +
+        if(m_wlmAccount->proxyType() == QNetworkProxy::Socks5Proxy )
+            m_preferencesWidget->m_radioProxySocks5->setChecked( true );
+        else
+            m_preferencesWidget->m_radioProxyHttp->setChecked( true );
+
         bool connected = account->isConnected();
         if ( connected )
             m_preferencesWidget->m_warning->hide();
@@ -136,6 +150,22 @@
         config->writeEntry( "serverPort", "1863" );
     }
 
+    if (m_preferencesWidget->optionEnableProxy->isChecked() ) {
+        config->writeEntry( "enableProxy", true );
+        config->writeEntry( "proxyHost", \
m_preferencesWidget->m_proxyHost->text().trimmed() ); +        config->writeEntry( \
"proxyPort", m_preferencesWidget->m_proxyPort->value()  ); +        \
config->writeEntry( "proxyUsername", m_preferencesWidget->m_proxyUsername->text() ); \
+        config->writeEntry( "proxyPassword", \
m_preferencesWidget->m_proxyPassword->text() ); +        \
if(m_preferencesWidget->m_radioProxyHttp->isChecked()) +            \
config->writeEntry( "proxyType", (uint)QNetworkProxy::HttpProxy ); +        else
+            config->writeEntry( "proxyType", (uint)QNetworkProxy::Socks5Proxy );
+    }
+    else {
+        config->writeEntry( "enableProxy", false );
+    }
+
+
     if ( wlmAccount->isConnected() )
     {
         QSet<QString> allowList = wlmAccount->allowList();
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmaccount.cpp #987422:987423
@@ -334,6 +334,37 @@
     return configGroup()->readEntry( "serverPort" , 1863 );
 }
 
+QString WlmAccount::proxyUsername() const
+{
+    return configGroup()->readEntry( "proxyUsername" );
+}
+
+QString WlmAccount::proxyPassword() const
+{
+    return configGroup()->readEntry( "proxyPassword" );
+}
+
+QString WlmAccount::proxyHost() const
+{
+    return configGroup()->readEntry( "proxyHost" );
+}
+
+uint WlmAccount::proxyType() const
+{
+    return configGroup()->readEntry( "proxyType", 0 );
+}
+
+uint WlmAccount::proxyPort() const
+{
+    return configGroup()->readEntry( "proxyPort", 8080 );
+}
+
+bool WlmAccount::isProxyEnabled() const
+{
+    return configGroup()->readEntry( "enableProxy", false );
+}
+
+
 void
 WlmAccount::gotNewContact (const MSN::ContactList & list,
                            const QString & passport,
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmaccount.h #987422:987423
@@ -95,6 +95,13 @@
     QString serverName() const;
     uint serverPort() const;
 
+    bool isProxyEnabled() const;
+    QString proxyHost() const;
+    uint proxyPort() const;
+    QString proxyUsername() const;
+    QString proxyPassword() const;
+    uint proxyType() const;
+
     WlmServer * server ();
 
     WlmChatManager * chatManager ()
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmlibmsn.cpp #987422:987423
@@ -676,7 +676,7 @@
 void *
 Callbacks::connectToServer (std::string hostname, int port, bool * connected, bool \
isSSL)  {
-    WlmSocket *a = new WlmSocket (mainConnection, isSSL);
+    WlmSocket *a = new WlmSocket (mainConnection, isSSL, m_server);
     if(!a)
         return NULL;
 
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmsocket.cpp #987422:987423
@@ -17,10 +17,14 @@
 #include "wlmsocket.h"
 
 #include <QTimer>
+#include <QNetworkProxy>
 
 #include "kopetesockettimeoutwatcher.h"
+#include "kopeteaccount.h"
+#include "wlmaccount.h"
+#include "wlmserver.h"
 
-WlmSocket::WlmSocket(MSN::NotificationServerConnection * mainConnection, bool isSSL)
+WlmSocket::WlmSocket(MSN::NotificationServerConnection * mainConnection, bool isSSL, \
WlmServer* server)  : mMainConnection(mainConnection), mIsSSL(isSSL), mPingTimer(0)
 {
     QObject::connect( this, SIGNAL(connected()), this, SLOT(connectionReady()) );
@@ -31,6 +35,20 @@
     Kopete::SocketTimeoutWatcher* timeoutWatcher = \
Kopete::SocketTimeoutWatcher::watch( this );  if ( timeoutWatcher )
         connect( timeoutWatcher, SIGNAL(error(QAbstractSocket::SocketError)), this, \
SIGNAL(error(QAbstractSocket::SocketError)) ); +
+    if (server && server->m_account)
+    {
+        WlmAccount *acc= server->m_account;
+        if(acc->isProxyEnabled())
+        {
+            QString proxyHost = acc->proxyHost();
+            uint proxyPort = acc->proxyPort();
+            QNetworkProxy::ProxyType proxyType = (QNetworkProxy::ProxyType) \
acc->proxyType(); +            QString proxyUsername = acc->proxyUsername();
+            QString proxyPassword = acc->proxyPassword();
+            setProxy(QNetworkProxy(proxyType, proxyHost, proxyPort, proxyUsername, \
proxyPassword)); +        }
+    }
 }
 
 WlmSocket::~WlmSocket()
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmsocket.h #987422:987423
@@ -22,12 +22,13 @@
 #include <msn/msn.h>
 
 class QTimer;
+class WlmServer;
 
 class WlmSocket : public QSslSocket
 {
   Q_OBJECT 
 public:
-    explicit WlmSocket( MSN::NotificationServerConnection * mainConnection, bool \
isSSL = false ); +    explicit WlmSocket( MSN::NotificationServerConnection * \
mainConnection, bool isSSL = false, WlmServer* server = NULL );  ~WlmSocket();
 
     bool isSSL() const { return mIsSSL; }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic