[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/akonadi/exchange
From: Shaheed Haque <srhaque () theiet ! org>
Date: 2012-03-08 18:40:25
Message-ID: 20120308184025.2AD66AC897 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1284467 by shaheed:
Beginning of "change password" support. Not yet working!
M +2 -0 CMakeLists.txt
M +5 -6 calendar/excalresource.cpp
M +13 -0 connector/mapiconnector2.cpp
M +5 -0 connector/mapiconnector2.h
M +5 -6 contacts/exgalresource.cpp
M +5 -6 mail/exmailresource.cpp
M +3 -2 mapibrowser/mapibrowser.cpp
A ui/changepassworddialog.cpp [License: GPL (v3+)]
A ui/changepassworddialog.h [License: GPL (v3+)]
A ui/changepassworddialog.ui
M +5 -5 ui/createprofiledialog.cpp
M +5 -5 ui/createprofiledialog.h
M +21 -19 ui/createprofiledialog.ui
M +57 -35 ui/profiledialog.cpp
M +8 -6 ui/profiledialog.h
M +37 -12 ui/profiledialog.ui
--- trunk/playground/pim/akonadi/exchange/CMakeLists.txt #1284466:1284467
@@ -64,11 +64,13 @@
set( RESOURCE_EXCHANGE_UI_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/ui/profiledialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ui/createprofiledialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ui/changepassworddialog.cpp
)
# define global path to the UI files for every resource to use
set( RESOURCE_EXCHANGE_UI_FILES
${CMAKE_CURRENT_SOURCE_DIR}/ui/profiledialog.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/createprofiledialog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/ui/changepassworddialog.ui
)
--- trunk/playground/pim/akonadi/exchange/calendar/excalresource.cpp #1284466:1284467
@@ -197,14 +197,13 @@
void ExCalResource::configure( WId windowId )
{
- ProfileDialog dlgConfig(Settings::self()->profileName());
- if (windowId)
+ ProfileDialog dlgConfig;
+ dlgConfig.setProfileName(Settings::self()->profileName());
+ if (windowId) {
KWindowSystem::setMainWindow(&dlgConfig, windowId);
-
+ }
if (dlgConfig.exec() == KDialog::Accepted) {
-
- QString profile = dlgConfig.getProfileName();
- Settings::self()->setProfileName( profile );
+ Settings::self()->setProfileName(dlgConfig.profileName());
Settings::self()->writeConfig();
synchronize();
--- trunk/playground/pim/akonadi/exchange/connector/mapiconnector2.cpp \
#1284466:1284467 @@ -1687,6 +1687,19 @@
return true;
}
+bool MapiProfiles::updatePassword(QString profile, QString oldPassword, QString \
newPassword) +{
+ if (!init()) {
+ return false;
+ }
+
+ if (MAPI_E_SUCCESS != ChangeProfilePassword(m_context, profile.toUtf8(), \
oldPassword.toUtf8(), newPassword.toUtf8())) { + error() << "cannot change password \
profile:" << profile << mapiError(); + return false;
+ }
+ return true;
+}
+
MapiProperty::MapiProperty(SPropValue &property) :
m_property(property)
{
--- trunk/playground/pim/akonadi/exchange/connector/mapiconnector2.h #1284466:1284467
@@ -405,6 +405,11 @@
bool add(QString profile, QString username, QString password, QString domain, \
QString server);
/**
+ * Modify an existing profile's password.
+ */
+ bool updatePassword(QString profile, QString oldPassword, QString newPassword);
+
+ /**
* Remove a profile.
*/
bool remove(QString profile);
--- trunk/playground/pim/akonadi/exchange/contacts/exgalresource.cpp #1284466:1284467
@@ -1019,14 +1019,13 @@
void ExGalResource::configure( WId windowId )
{
- ProfileDialog dlgConfig(Settings::self()->profileName());
- if (windowId)
+ ProfileDialog dlgConfig;
+ dlgConfig.setProfileName(Settings::self()->profileName());
+ if (windowId) {
KWindowSystem::setMainWindow(&dlgConfig, windowId);
-
+ }
if (dlgConfig.exec() == KDialog::Accepted) {
-
- QString profile = dlgConfig.getProfileName();
- Settings::self()->setProfileName( profile );
+ Settings::self()->setProfileName(dlgConfig.profileName());
Settings::self()->writeConfig();
synchronize();
--- trunk/playground/pim/akonadi/exchange/mail/exmailresource.cpp #1284466:1284467
@@ -354,14 +354,13 @@
void ExMailResource::configure( WId windowId )
{
- ProfileDialog dlgConfig(Settings::self()->profileName());
- if (windowId)
+ ProfileDialog dlgConfig;
+ dlgConfig.setProfileName(Settings::self()->profileName());
+ if (windowId) {
KWindowSystem::setMainWindow(&dlgConfig, windowId);
-
+ }
if (dlgConfig.exec() == KDialog::Accepted) {
-
- QString profile = dlgConfig.getProfileName();
- Settings::self()->setProfileName( profile );
+ Settings::self()->setProfileName(dlgConfig.profileName());
Settings::self()->writeConfig();
synchronize();
--- trunk/playground/pim/akonadi/exchange/mapibrowser/mapibrowser.cpp \
#1284466:1284467 @@ -121,10 +121,11 @@
void mapibrowser::onManageProfiles()
{
- ProfileDialog dlgConfig(selectedProfile);
+ ProfileDialog dlgConfig;
+ dlgConfig.setProfileName(selectedProfile);
if (dlgConfig.exec() == QDialog::Accepted) {
- selectedProfile = dlgConfig.getProfileName();
+ selectedProfile = dlgConfig.profileName();
}
}
--- trunk/playground/pim/akonadi/exchange/ui/createprofiledialog.cpp #1284466:1284467
@@ -50,23 +50,23 @@
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
}
-QString CreateProfileDialog::getProfileName()
+QString CreateProfileDialog::profileName() const
{
return leProfile->text();
}
-QString CreateProfileDialog::getUsername()
+QString CreateProfileDialog::username() const
{
return leUsername->text();
}
-QString CreateProfileDialog::getPassword()
+QString CreateProfileDialog::password() const
{
return lePassword->text();
}
-QString CreateProfileDialog::getServer()
+QString CreateProfileDialog::server() const
{
return leServer->text();
}
-QString CreateProfileDialog::getDomain()
+QString CreateProfileDialog::domain() const
{
return leDomain->text();
}
--- trunk/playground/pim/akonadi/exchange/ui/createprofiledialog.h #1284466:1284467
@@ -31,11 +31,11 @@
explicit CreateProfileDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
virtual ~CreateProfileDialog() {}
- QString getProfileName();
- QString getUsername();
- QString getPassword();
- QString getServer();
- QString getDomain();
+ QString profileName() const;
+ QString username() const;
+ QString password() const;
+ QString server() const;
+ QString domain() const;
private slots:
void slotValidateData();
--- trunk/playground/pim/akonadi/exchange/ui/createprofiledialog.ui #1284466:1284467
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>410</width>
+ <width>467</width>
<height>216</height>
</rect>
</property>
@@ -30,7 +30,7 @@
</property>
</widget>
</item>
- <item row="0" column="1" colspan="2">
+ <item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="leProfile"/>
</item>
<item row="1" column="0">
@@ -43,10 +43,23 @@
</property>
</widget>
</item>
- <item row="1" column="1" colspan="2">
+ <item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="leServer"/>
</item>
<item row="2" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>&Domain</string>
+ </property>
+ <property name="buddy">
+ <cstring>leDomain</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="leDomain"/>
+ </item>
+ <item row="2" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&Username</string>
@@ -56,7 +69,7 @@
</property>
</widget>
</item>
- <item row="2" column="1" colspan="2">
+ <item row="2" column="3">
<widget class="QLineEdit" name="leUsername"/>
</item>
<item row="3" column="0">
@@ -69,22 +82,13 @@
</property>
</widget>
</item>
- <item row="3" column="1" colspan="2">
- <widget class="QLineEdit" name="lePassword"/>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>&Domain</string>
+ <item row="3" column="1" colspan="3">
+ <widget class="QLineEdit" name="lePassword">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
</property>
- <property name="buddy">
- <cstring>leDomain</cstring>
- </property>
</widget>
</item>
- <item row="4" column="1" colspan="2">
- <widget class="QLineEdit" name="leDomain"/>
- </item>
</layout>
</widget>
</item>
@@ -103,9 +107,7 @@
<tabstops>
<tabstop>leProfile</tabstop>
<tabstop>leServer</tabstop>
- <tabstop>leUsername</tabstop>
<tabstop>lePassword</tabstop>
- <tabstop>leDomain</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
--- trunk/playground/pim/akonadi/exchange/ui/profiledialog.cpp #1284466:1284467
@@ -22,61 +22,53 @@
#include <QDebug>
#include <KMessageBox>
+#include "changepassworddialog.h"
#include "createprofiledialog.h"
-ProfileDialog::ProfileDialog(QString selectedProfile, QWidget* parent)
- : QDialog(parent), selectedProfile(selectedProfile)
+ProfileDialog::ProfileDialog(QWidget *parent) :
+ QDialog(parent)
{
setupUi(this);
- connect(btnCreate, SIGNAL(clicked()), this, SLOT(slotCreateNewProfile()));
- connect(btnRemove, SIGNAL(clicked()), this, SLOT(slotRemoveProfile()));
+ connect(btnCreate, SIGNAL(clicked()), this, SLOT(slotCreateProfile()));
+ connect(btnUpdate, SIGNAL(clicked()), this, SLOT(slotUpdateProfile()));
+ connect(btnDelete, SIGNAL(clicked()), this, SLOT(slotDeleteProfile()));
- connect(listWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), \
+ connect(profileList, SIGNAL(currentItemChanged(QListWidgetItem*, \
QListWidgetItem*)), this, SLOT(newProfileSelected(QListWidgetItem*, \
QListWidgetItem*)));
QTimer::singleShot(0, this, SLOT(readMapiProfiles()));
- QTimer::singleShot(0, this, SLOT(slotValidate()));
}
void ProfileDialog::readMapiProfiles()
{
- listWidget->clear();
+ profileList->clear();
- QStringList profiles = m_profiles.list();
-
- bool profileExist = false;
- foreach (QString profile, profiles) {
- QListWidgetItem* item = new QListWidgetItem(profile, listWidget);
- if (selectedProfile == profile) {
- listWidget->setCurrentItem(item);
- profileExist = true;
+ foreach (QString entry, m_profiles.list()) {
+ QListWidgetItem* item = new QListWidgetItem(entry, profileList);
+ if (kcfg_ProfileName->text() == entry) {
+ profileList->setCurrentItem(item);
}
}
-
- if (!profileExist)
- selectedProfile.clear();
-
updateSelectedProfile();
}
void ProfileDialog::updateSelectedProfile()
{
- labelSelectedProfile->setText(i18n("Selected Profile:")+QString::fromLatin1(" \
")+selectedProfile); + if (profileList->currentItem()) {
+ kcfg_ProfileName->setText(profileList->currentItem()->text());
+ } else {
+ kcfg_ProfileName->clear();
+ }
slotValidate();
}
void ProfileDialog::newProfileSelected(QListWidgetItem* newItem, QListWidgetItem* \
lastItem) {
+ Q_UNUSED(newItem)
Q_UNUSED(lastItem)
- if (newItem != NULL) {
- selectedProfile = newItem->text();
- } else {
- selectedProfile.clear();
- }
-
updateSelectedProfile();
}
@@ -84,35 +76,65 @@
{
bool valid = false;
- if (!selectedProfile.isEmpty()) {
+ if (kcfg_ProfileName->text().isEmpty()) {
+ goto DONE;
+ }
valid = true;
- }
-
+DONE:
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
}
-void ProfileDialog::slotCreateNewProfile()
+void ProfileDialog::slotCreateProfile()
{
CreateProfileDialog dlg(this);
if (dlg.exec() == QDialog::Accepted) {
- bool ok = m_profiles.add(dlg.getProfileName(), dlg.getUsername(), \
dlg.getPassword(), dlg.getDomain(), dlg.getServer());
- if (!ok)
+ bool ok = m_profiles.add(dlg.profileName(), dlg.username(), dlg.password(), \
dlg.domain(), dlg.server()); + if (!ok) {
KMessageBox::error(this, i18n("An error occurred during the creation of the new \
profile")); + } else {
+ kcfg_ProfileName->setText(dlg.profileName());
+ }
readMapiProfiles();
}
}
-void ProfileDialog::slotRemoveProfile()
+void ProfileDialog::slotUpdateProfile()
{
- if (selectedProfile.isEmpty())
+ ChangePasswordDialog dlg(this);
+ dlg.setProfileName(kcfg_ProfileName->text());
+ if (dlg.exec() == QDialog::Accepted) {
+ bool ok = m_profiles.updatePassword(kcfg_ProfileName->text(), dlg.oldPassword(), \
dlg.newPassword()); + if (!ok) {
+ KMessageBox::error(this, i18n("An error occurred during the changing of the \
password: %1", mapiError())); + }
+ readMapiProfiles();
+ }
+}
+
+void ProfileDialog::slotDeleteProfile()
+{
+ if (kcfg_ProfileName->text().isEmpty())
return;
if (KMessageBox::questionYesNo(this, i18n("Do you really want to delete the \
selected profile?")) == KMessageBox::Yes) { bool ok = \
m_profiles.remove(selectedProfile);
- if (!ok)
+ if (!ok) {
KMessageBox::error(this, i18n("An error occurred during the deletion of the \
selected profile")); + }
readMapiProfiles();
}
}
+QString ProfileDialog::profileName() const
+{
+ return kcfg_ProfileName->text();
+}
+
+void ProfileDialog::setProfileName(QString profile)
+{
+ kcfg_ProfileName->setText(profile);
+ readMapiProfiles();
+}
+
+
#include "profiledialog.moc"
--- trunk/playground/pim/akonadi/exchange/ui/profiledialog.h #1284466:1284467
@@ -17,8 +17,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __EXCALCONFIG_H__
-#define __EXCALCONFIG_H__
+#ifndef __PROFILEDIALOG_H__
+#define __PROFILEDIALOG_H__
#include <QDialog>
#include "ui_profiledialog.h"
@@ -28,18 +28,20 @@
{
Q_OBJECT
public:
- explicit ProfileDialog(QString selectedProfile, QWidget *parent = 0);
+ explicit ProfileDialog(QWidget *parent = 0);
virtual ~ProfileDialog() {}
- QString getProfileName() { return selectedProfile; }
+ QString profileName() const;
+ void setProfileName(QString profile);
private slots:
void readMapiProfiles();
void newProfileSelected(QListWidgetItem* newItem, QListWidgetItem* lastItem);
void slotValidate();
- void slotCreateNewProfile();
- void slotRemoveProfile();
+ void slotCreateProfile();
+ void slotUpdateProfile();
+ void slotDeleteProfile();
private:
void updateSelectedProfile();
--- trunk/playground/pim/akonadi/exchange/ui/profiledialog.ui #1284466:1284467
@@ -6,43 +6,67 @@
<rect>
<x>0</x>
<y>0</y>
- <width>386</width>
- <height>320</height>
+ <width>466</width>
+ <height>310</height>
</rect>
</property>
<property name="windowTitle">
<string>Select Profile</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
+ <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Profiles</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
+ <widget class="QListWidget" name="profileList"/>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
<widget class="QPushButton" name="btnCreate">
<property name="text">
- <string>&Create Profile</string>
+ <string>&Add</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="btnRemove">
+ <widget class="QPushButton" name="btnUpdate">
<property name="text">
- <string>&Remove Profile</string>
+ <string>&Change Password</string>
</property>
</widget>
</item>
- </layout>
+ <item>
+ <widget class="QPushButton" name="btnDelete">
+ <property name="text">
+ <string>&Remove</string>
+ </property>
+ </widget>
</item>
<item>
- <widget class="QListWidget" name="listWidget"/>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
</item>
+ </layout>
+ </item>
+ </layout>
+ </item>
<item>
- <widget class="QLabel" name="labelSelectedProfile">
+ <widget class="QLabel" name="kcfg_ProfileName">
<property name="text">
<string>TextLabel</string>
</property>
@@ -61,9 +85,10 @@
</layout>
</widget>
<tabstops>
+ <tabstop>profileList</tabstop>
<tabstop>btnCreate</tabstop>
- <tabstop>btnRemove</tabstop>
- <tabstop>listWidget</tabstop>
+ <tabstop>btnUpdate</tabstop>
+ <tabstop>btnDelete</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic