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

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/protocols/wlm
From:       Roman Jarosz <kedgedev () centrum ! cz>
Date:       2008-11-15 23:14:06
Message-ID: 1226790846.962526.4518.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 884833 by rjarosz:

Allow user to delete contacts from allow/block list if contact isn't in contact list.
Fix block/unblock we can call unblock/block only if the contact is in opposite list.
Always add contacts on login to m_serverSideContactsPassports.



 M  +2 -2      wlmaccount.cpp  
 M  +2 -0      wlmaccount.h  
 M  +10 -4     wlmaccountpreferences.ui  
 M  +12 -2     wlmcontact.cpp  
 M  +72 -9     wlmeditaccountwidget.cpp  
 M  +12 -2     wlmeditaccountwidget.h  


--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmaccount.cpp #884832:884833
@@ -572,6 +572,8 @@
         MSN::Buddy * b = (*it).second;
         QString passport = (*it).first.c_str();
 
+        if (b->lists & MSN::LST_AB)
+            m_serverSideContactsPassports.insert (b->userName.c_str());
         if ( b->lists & MSN::LST_AL )
             m_allowList.insert( passport );
         if ( b->lists & MSN::LST_BL )
@@ -592,7 +594,6 @@
                 // only add users in forward list
                 if (b->lists & MSN::LST_AB)
                 {
-                    m_serverSideContactsPassports.insert (b->userName.c_str());
                     metacontact = addContact (b->userName.c_str (), QString(), 0L, \
Kopete::Account::DontChangeKABC);  
                     Kopete::Contact * newcontact = contacts ()[b->userName.c_str \
()]; @@ -618,7 +619,6 @@
             {
                 Kopete::Group * g = Kopete::ContactList::self ()->findGroup (QString \
((*i)->name.c_str ()).toAscii ());  
-                m_serverSideContactsPassports.insert (b->userName.c_str());
                 if (g)
                     metacontact = addContact (b->userName.c_str (), QString(), g, \
Kopete::Account::DontChangeKABC);  else
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmaccount.h #884832:884833
@@ -114,6 +114,8 @@
 
     QSet<QString> blockList() const { return m_blockList; }
 
+    QSet<QString> serverSideContacts() const { return m_serverSideContactsPassports; \
} +
     public
         slots:
         /**
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmaccountpreferences.ui #884832:884833
@@ -214,10 +214,18 @@
           </widget>
          </item>
          <item row="2" column="0" >
-          <widget class="QListWidget" name="m_AL" />
+          <widget class="QListWidget" name="m_AL" >
+           <property name="contextMenuPolicy" >
+            <enum>Qt::ActionsContextMenu</enum>
+           </property>
+          </widget>
          </item>
          <item row="2" column="4" >
-          <widget class="QListWidget" name="m_BL" />
+          <widget class="QListWidget" name="m_BL" >
+           <property name="contextMenuPolicy" >
+            <enum>Qt::ActionsContextMenu</enum>
+           </property>
+          </widget>
          </item>
         </layout>
        </item>
@@ -373,8 +381,6 @@
         </spacer>
        </item>
       </layout>
-      <zorder>groupBox_4</zorder>
-      <zorder></zorder>
      </widget>
     </widget>
    </item>
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmcontact.cpp #884832:884833
@@ -143,9 +143,19 @@
 
     WlmAccount* wlmAccount = dynamic_cast<WlmAccount*>(account());
     if (block)
-        wlmAccount->server()->mainConnection->blockContact( \
contactId().toAscii().data() ); +    {
+        if ( wlmAccount->isOnAllowList(contactId()) )
+            wlmAccount->server()->mainConnection->removeFromList( MSN::LST_AL, \
contactId().toAscii().data() ); +
+        wlmAccount->server()->mainConnection->addToList( MSN::LST_BL, \
contactId().toAscii().data() ); +    }
     else
-        wlmAccount->server()->mainConnection->unblockContact( \
contactId().toAscii().data() ); +    {
+        if ( wlmAccount->isOnBlockList(contactId()) )
+            wlmAccount->server()->mainConnection->removeFromList( MSN::LST_BL, \
contactId().toAscii().data() ); +
+        wlmAccount->server()->mainConnection->addToList( MSN::LST_AL, \
contactId().toAscii().data() ); +    }
 }
 
 void
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmeditaccountwidget.cpp #884832:884833
@@ -33,7 +33,7 @@
 #include "wlmprotocol.h"
 
 WlmEditAccountWidget::WlmEditAccountWidget (QWidget * parent, Kopete::Account * \
                account)
- : QWidget (parent), KopeteEditAccountWidget(account)
+ : QWidget (parent), KopeteEditAccountWidget(account), m_wlmAccount(0)
 {
     m_preferencesWidget = new Ui::WlmAccountPreferences ();
     m_preferencesWidget->setupUi (this);
@@ -42,18 +42,18 @@
     if ( account )
     {
         KConfigGroup * config = account->configGroup();
-        WlmAccount* wlmAccount = static_cast<WlmAccount*>(account);
+        m_wlmAccount = static_cast<WlmAccount*>(account);
 
-        m_preferencesWidget->m_passport->setText( wlmAccount->accountId() );
-        m_preferencesWidget->m_password->load( &wlmAccount->password() );
+        m_preferencesWidget->m_passport->setText( m_wlmAccount->accountId() );
+        m_preferencesWidget->m_password->load( &m_wlmAccount->password() );
 
         m_preferencesWidget->m_passport->setReadOnly( true );
         m_preferencesWidget->m_autologin->setChecked( account->excludeConnect()  );
-        if ( wlmAccount->serverName() != "messenger.hotmail.com" || \
wlmAccount->serverPort() != 1863 ) +        if ( m_wlmAccount->serverName() != \
                "messenger.hotmail.com" || m_wlmAccount->serverPort() != 1863 )
             m_preferencesWidget->optionOverrideServer->setChecked( true );
 
-        m_preferencesWidget->m_serverName->setText( wlmAccount->serverName() );
-        m_preferencesWidget->m_serverPort->setValue( wlmAccount->serverPort() );
+        m_preferencesWidget->m_serverName->setText( m_wlmAccount->serverName() );
+        m_preferencesWidget->m_serverPort->setValue( m_wlmAccount->serverPort() );
 
         bool connected = account->isConnected();
         if ( connected )
@@ -65,11 +65,22 @@
         m_preferencesWidget->m_allowButton->setIcon( KIcon( "arrow-left" ) );
         m_preferencesWidget->m_blockButton->setIcon( KIcon( "arrow-right" ) );
 
-        foreach ( QString contact, wlmAccount->allowList() )
+        foreach ( QString contact, m_wlmAccount->allowList() )
             m_preferencesWidget->m_AL->addItem( contact );
 
-        foreach ( QString contact, wlmAccount->blockList() )
+        foreach ( QString contact, m_wlmAccount->blockList() )
             m_preferencesWidget->m_BL->addItem( contact );
+
+        m_deleteActionAL = new QAction( i18n( "Delete" ), m_preferencesWidget->m_AL \
); +        m_preferencesWidget->m_AL->addAction( m_deleteActionAL );
+
+        m_deleteActionBL = new QAction( i18n( "Delete" ), m_preferencesWidget->m_BL \
); +        m_preferencesWidget->m_BL->addAction( m_deleteActionBL );
+
+        connect( m_preferencesWidget->m_AL, SIGNAL(itemSelectionChanged()), this, \
SLOT(updateActionsAL()) ); +        connect( m_preferencesWidget->m_BL, \
SIGNAL(itemSelectionChanged()), this, SLOT(updateActionsBL()) ); +        connect( \
m_deleteActionAL, SIGNAL(triggered(bool)), this, SLOT(deleteALItem()) ); +        \
connect( m_deleteActionBL, SIGNAL(triggered(bool)), this, SLOT(deleteBLItem()) );  }
 
     connect( m_preferencesWidget->m_allowButton, SIGNAL(clicked()), this, \
SLOT(slotAllow()) ); @@ -124,6 +135,12 @@
             if ( !blockList.contains(contact) )
                 wlmAccount->server()->mainConnection->blockContact( \
contact.toAscii().data() );  }
+
+        foreach ( QString contact, m_deletedContactsAL )
+            wlmAccount->server()->mainConnection->removeFromList( MSN::LST_AL, \
contact.toAscii().data() ); +
+        foreach ( QString contact, m_deletedContactsBL )
+            wlmAccount->server()->mainConnection->removeFromList( MSN::LST_BL, \
contact.toAscii().data() );  }
 
     return account ();
@@ -160,6 +177,52 @@
     m_preferencesWidget->m_BL->addItem( item );
 }
 
+void WlmEditAccountWidget::updateActionsAL()
+{
+    bool enableDeleteAction = false;
+
+    if ( m_wlmAccount && !m_preferencesWidget->m_AL->selectedItems().isEmpty() )
+        enableDeleteAction = !m_wlmAccount->serverSideContacts().contains( \
m_preferencesWidget->m_AL->selectedItems().at(0)->text() ); +
+    m_deleteActionAL->setEnabled( enableDeleteAction );
+}
+
+void WlmEditAccountWidget::updateActionsBL()
+{
+    bool enableDeleteAction = false;
+
+    if ( m_wlmAccount && !m_preferencesWidget->m_BL->selectedItems().isEmpty() )
+        enableDeleteAction = !m_wlmAccount->serverSideContacts().contains( \
m_preferencesWidget->m_BL->selectedItems().at(0)->text() ); +
+    m_deleteActionBL->setEnabled( enableDeleteAction );
+}
+
+void WlmEditAccountWidget::deleteALItem()
+{
+    if ( m_wlmAccount && !m_preferencesWidget->m_AL->selectedItems().isEmpty() )
+    {
+        QListWidgetItem *item = m_preferencesWidget->m_AL->selectedItems().at(0);
+        if ( !m_wlmAccount->serverSideContacts().contains( item->text() ) )
+        {
+            m_deletedContactsAL.insert( item->text() );
+            m_preferencesWidget->m_AL->takeItem( m_preferencesWidget->m_AL->row( \
item ) ); +        }
+    }
+}
+
+void WlmEditAccountWidget::deleteBLItem()
+{
+    if ( m_wlmAccount && !m_preferencesWidget->m_BL->selectedItems().isEmpty() )
+    {
+        QListWidgetItem *item = m_preferencesWidget->m_BL->selectedItems().at(0);
+        if ( !m_wlmAccount->serverSideContacts().contains( item->text() ) )
+        {
+            m_deletedContactsBL.insert( item->text() );
+            m_preferencesWidget->m_BL->takeItem( m_preferencesWidget->m_BL->row( \
item ) ); +        }
+    }
+}
+
 void WlmEditAccountWidget::slotOpenRegister()
 {
     KToolInvocation::invokeBrowser( "http://register.passport.net/"  );
--- trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmeditaccountwidget.h #884832:884833
@@ -18,6 +18,7 @@
 #define WLMEDITACCOUNTWIDGET_H
 
 #include <QWidget>
+#include <QSet>
 #include <editaccountwidget.h>
 
 namespace Kopete
@@ -28,6 +29,7 @@
 {
     class WlmAccountPreferences;
 }
+class WlmAccount;
 
 /**
  * A widget for editing this protocol's accounts
@@ -53,11 +55,19 @@
 private slots:
     void slotAllow();
     void slotBlock();
+    void updateActionsAL();
+    void updateActionsBL();
+    void deleteALItem();
+    void deleteBLItem();
     void slotOpenRegister();
 
 private:
-      Kopete::Account * m_account;
-      Ui::WlmAccountPreferences * m_preferencesWidget;
+    QSet<QString> m_deletedContactsAL;
+    QSet<QString> m_deletedContactsBL;
+    QAction* m_deleteActionAL;
+    QAction* m_deleteActionBL;
+    WlmAccount* m_wlmAccount;
+    Ui::WlmAccountPreferences * m_preferencesWidget;
 };
 
 #endif


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

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