From kopete-devel Sun Apr 13 19:02:23 2008 From: Dennis =?iso-8859-1?q?Nienh=FCser?= Date: Sun, 13 Apr 2008 19:02:23 +0000 To: kopete-devel Subject: [kopete-devel] [PATCH] Chat Window Style selection via KNS2 Message-Id: <200804132102.30504.earthwings () gentoo ! org> X-MARC-Message: https://marc.info/?l=kopete-devel&m=120811342113977 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============2139410865==" --===============2139410865== Content-Type: multipart/signed; boundary="nextPart4448063.nXm4DtjKr2"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart4448063.nXm4DtjKr2 Content-Type: multipart/mixed; boundary="Boundary-01=_AjlAIcoxTdO6kUP" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_AjlAIcoxTdO6kUP Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I had another look at KNS2, which now reports changed items and therefore=20 allows for an easier integration in Kopete.=20 The patch attached comes up with a behaviour for chat window style download= ing=20 similar to the one in KDE 3.5. The download however is done by KNS2 (which= =20 has a nice integrated download mechanism that doesn't get in one's way) and= =20 the installation deferred to the point where the KNS2 dialog is closed. Please review and comment. Regards, Dennis --Boundary-01=_AjlAIcoxTdO6kUP Content-Type: text/x-diff; charset="us-ascii"; name="chatstyle_kns2.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="chatstyle_kns2.diff" Index: kopete/kopete/config/chatwindow/chatwindowconfig.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- kopete/kopete/config/chatwindow/chatwindowconfig.h (revision 796013) +++ kopete/kopete/config/chatwindow/chatwindowconfig.h (working copy) @@ -52,6 +52,7 @@ private slots: //----- Style TAB --------------------- void slotInstallChatStyle(); + int installChatStyle(const KUrl &styleToInstall); void slotDeleteChatStyle(); void slotChatStyleSelected(); void slotChatStyleVariantSelected(const QString &variantName); Index: kopete/kopete/config/chatwindow/chatwindowconfig_style.ui =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- kopete/kopete/config/chatwindow/chatwindowconfig_style.ui (revision 7= 96013) +++ kopete/kopete/config/chatwindow/chatwindowconfig_style.ui (working copy) @@ -197,7 +197,7 @@ =2D false + true Get new Chat Window styles over the Internet Index: kopete/kopete/config/chatwindow/CMakeLists.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- kopete/kopete/config/chatwindow/CMakeLists.txt (revision 796013) +++ kopete/kopete/config/chatwindow/CMakeLists.txt (working copy) @@ -21,7 +21,7 @@ kde4_add_plugin(kcm_kopete_chatwindowconfig ${kcm_kopete_chatwindowconfig_= PART_SRCS}) =20 =20 =2Dtarget_link_libraries(kcm_kopete_chatwindowconfig ${KDE4_KUTILS_LIBS} ko= pete kopetechatwindow_shared ${KDE4_KNEWSTUFF_LIBS} ) +target_link_libraries(kcm_kopete_chatwindowconfig ${KDE4_KUTILS_LIBS} kope= te kopetechatwindow_shared ${KDE4_KNEWSTUFF2_LIBS} ) =20 install(TARGETS kcm_kopete_chatwindowconfig DESTINATION ${PLUGIN_INSTALL_D= IR}) =20 Index: kopete/kopete/config/chatwindow/chatwindowconfig.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- kopete/kopete/config/chatwindow/chatwindowconfig.cpp (revision 796013) +++ kopete/kopete/config/chatwindow/chatwindowconfig.cpp (working copy) @@ -45,21 +45,13 @@ #include #include #include =2D#include // KNewStuff #include #include #include +#include =20 =2D#ifdef __GNUC__ =2D#warning "Port KNS changes!" =2D#endif =2D#if 0 =2D#include // knewstuff emoticon and chatwind= ow fetching =2D#include // " =2D#include // " =2D#include // " =2D#include // " =2D#endif +// KNewStuff +#include =20 // For Kopete Chat Window Style configuration and preview. #include @@ -146,63 +138,6 @@ FakeIdentity *m_identity; }; =20 =2D =2D#ifdef __GNUC__ =2D#warning "Port KNS changes!" =2D#endif =2D#if 0 =2Dclass KopeteStyleNewStuff : public KNewStuff =2D{ =2Dpublic: =2D KopeteStyleNewStuff(const QString &type, QWidget *parentWidget =3D 0) =2D : KNewStuff( type, parentWidget) =2D {} =2D =2D bool createUploadFile(const QString &) =2D { =2D return false; =2D } =2D =2D bool install(const QString &styleFilename) =2D { =2D int styleInstallReturn =3D 0; =2D styleInstallReturn =3D ChatWindowStyleManager::self()->installStyle( s= tyleFilename ); =2D =2D switch(styleInstallReturn) =2D { =2D case ChatWindowStyleManager::StyleInstallOk: =2D { =2D KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::In= formation, i18n("The Chat Window style was successfully installed."), i18n(= "Install successful") ); =2D return true; =2D } =2D case ChatWindowStyleManager::StyleCannotOpen: =2D { =2D KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Er= ror, i18n("The specified archive cannot be opened.\nMake sure that the arch= ive is valid ZIP or TAR archive."), i18n("Cannot open archive") ); =2D break; =2D } =2D case ChatWindowStyleManager::StyleNoDirectoryValid: =2D { =2D KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Er= ror, i18n("Could not find a suitable place to install the Chat Window style= in user directory."), i18n("Cannot find styles directory") ); =2D break; =2D } =2D case ChatWindowStyleManager::StyleNotValid: =2D { =2D KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Er= ror, i18n("The specified archive does not contain a valid Chat Window style= =2E"), i18n("Invalid Style") ); =2D break; =2D } =2D =2D case ChatWindowStyleManager::StyleUnknow: =2D default: =2D { =2D KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Er= ror, i18n("An unknow error occurred while trying to install the Chat Window= style."), i18n("Unknow error") ); =2D break; =2D } =2D } =2D return false; =2D } =2D}; =2D#endif =2D ChatWindowConfig::ChatWindowConfig(QWidget *parent, const QVariantList &ar= gs ) : KCModule( KopeteChatWindowConfigFactory::componentData(), parent, args = ), m_currentStyle (0L), m_loading(false), m_styleChanged(false), @@ -446,47 +381,54 @@ =20 void ChatWindowConfig::slotInstallChatStyle() { =2D KUrl styleToInstall =3D KFileDialog::getOpenUrl( KUrl(), QString::fromU= tf8("application/zip application/x-compressed-tar application/x-bzip-compre= ssed-tar"), this, i18n("Choose Chat Window style to install.") ); + int styleInstallReturn =3D installChatStyle(KFileDialog::getOpenUrl( KUrl= (), QString::fromUtf8("application/zip application/x-compressed-tar applica= tion/x-bzip-compressed-tar"), this, i18n("Choose Chat Window Style to insta= ll.") )); =20 + switch(styleInstallReturn) + { + case ChatWindowStyleManager::StyleCannotOpen: + { + KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("The spec= ified archive cannot be opened.\nMake sure that the archive is a valid ZIP = or TAR archive."), i18n("Cannot open archive") ); + break; + } + case ChatWindowStyleManager::StyleNoDirectoryValid: + { + KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("Could no= t find a suitable place to install the Chat Window Style."), i18n("Cannot f= ind styles directory") ); + break; + } + case ChatWindowStyleManager::StyleNotValid: + KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("The spec= ified archive does not contain a valid Chat Window Style."), i18n("Invalid = Style") ); + break; + case ChatWindowStyleManager::StyleInstallOk: + { + KMessageBox::queuedMessageBox( this, KMessageBox::Information, i18n("Th= e Chat Window Style was successfully installed."), i18n("Install successful= ") ); + break; + } + case ChatWindowStyleManager::StyleUnknow: + default: + { + KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("An unkno= wn error occurred while trying to install the Chat Window Style."), i18n("U= nknown error") ); + break; + } + } +} + +int ChatWindowConfig::installChatStyle(const KUrl &styleToInstall) +{ + int styleInstallReturn =3D ChatWindowStyleManager::StyleCannotOpen; + if( !styleToInstall.isEmpty() ) { QString stylePath; if( KIO::NetAccess::download( styleToInstall, stylePath, this ) ) { =2D int styleInstallReturn =3D 0; styleInstallReturn =3D ChatWindowStyleManager::self()->installStyle( st= ylePath ); =2D switch(styleInstallReturn) =2D { =2D case ChatWindowStyleManager::StyleCannotOpen: =2D { =2D KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("The = specified archive cannot be opened.\nMake sure that the archive is valid ZI= P or TAR archive."), i18n("Cannot open archive") ); =2D break; =2D } =2D case ChatWindowStyleManager::StyleNoDirectoryValid: =2D { =2D KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("Coul= d not find a suitable place to install the Chat Window style in user direct= ory."), i18n("Cannot find styles directory") ); =2D break; =2D } =2D case ChatWindowStyleManager::StyleNotValid: =2D KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("The = specified archive does not contain a valid Chat Window style."), i18n("Inva= lid Style") ); =2D break; =2D case ChatWindowStyleManager::StyleInstallOk: =2D { =2D KMessageBox::queuedMessageBox( this, KMessageBox::Information, i18n= ("The Chat Window style was successfully installed."), i18n("Install succes= sful") ); =2D break; =2D } =2D case ChatWindowStyleManager::StyleUnknow: =2D default: =2D { =2D KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("An u= nknow error occurred while trying to install the Chat Window style."), i18n= ("Unknow error") ); =2D break; =2D } =2D } =20 // removeTempFile check if the file is a temp file, so it's ok for loca= l files. KIO::NetAccess::removeTempFile( stylePath ); } } + + return styleInstallReturn; } =20 void ChatWindowConfig::slotDeleteChatStyle() @@ -499,35 +441,76 @@ QString styleName =3D m_styleUi.styleList->selectedItem()->text(); if( ChatWindowStyleManager::self()->removeStyle(styleName) ) { =2D KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18nc("@= info", "The style %1 was successfully deleted.", style= Name)); + KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18nc("@in= fo", "The Chat Window Style %1 was successfully delete= d.", styleName)); emitChanged(); } else { =2D KMessageBox::queuedMessageBox(this, KMessageBox::Sorry, i18nc("@info",= "An error occurred while trying to delete the %1 styl= e. Your account might not have permission to remove it.", styleName)); + KMessageBox::queuedMessageBox(this, KMessageBox::Sorry, i18nc("@info", "= An error occurred while trying to delete the %1 Chat W= indow Style. Your account might not have permission to remove it.", styleNa= me)); } } =20 void ChatWindowConfig::slotGetChatStyles() { =2D#ifdef __GNUC__ =2D#warning "Port KNS changes!" =2D#endif =2D#if 0 =2D // we need this because KNewStuffGeneric's install function isn't cleve= r enough =2D KopeteStyleNewStuff *kopeteNewStuff =3D new KopeteStyleNewStuff( "kopet= e/chatstyle", this ); =2D KNS::Engine *engine =3D new KNS::Engine( kopeteNewStuff, "kopete/chatst= yle", this ); =2D KNS::DownloadDialog *downloadDialog =3D new KNS::DownloadDialog( engine= , this ); =2D downloadDialog->setCategory( "kopete/chatstyle" ); =2D // you have to do this by hand when providing your own Engine =2D KNS::ProviderLoader *provider =3D new KNS::ProviderLoader( this ); =2D QObject::connect( provider, SIGNAL( providersLoaded(Provider::List*) ),= downloadDialog, SLOT( slotProviders (Provider::List *) ) ); =2D provider->load( "kopete/chatstyle", "http://download.kde.org/khotnewstu= ff/kopetestyles12-providers.xml" ); =2D downloadDialog->exec(); =2D delete downloadDialog; =2D delete kopeteNewStuff; + KConfigGroup configGrp(KGlobal::config(), "KNewStuff2"); + configGrp.writeEntry("ProvidersUrl", "http://download.kde.org/khotnewstuf= f/kopetestyles12-providers.xml"); + configGrp.writeEntry("TargetDir", "kopete_chatstyles"); + configGrp.sync(); +=09 + KNS::Engine *engine =3D new KNS::Engine(); + engine->init(configGrp.config()->name()); +=09 + KNS::Entry::List entries =3D engine->downloadDialogModal(this); + + if ( entries.size() > 0 ) + { + int correctlyInstalled(0); + foreach( KNS::Entry* entry, entries ) + { + if ( entry->status() =3D=3D KNS::Entry::Installed && entry->installedFi= les().size() > 0 ) + { + KUrl styleFile( entry->installedFiles().at(0) ); + int result =3D installChatStyle( styleFile ); + + QString packageName(entry->name().representation()); + QString errorTitle =3D i18nc("@title:window", "Chat Window Style %1 installation", packageName); + switch(result) + { + case ChatWindowStyleManager::StyleCannotOpen: + { + KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18nc("@inf= o", "The specified archive %1 cannot be opened.\nMake = sure that the archive is a valid ZIP or TAR archive.", styleFile.pathOrUrl(= )), errorTitle); + break; + } + case ChatWindowStyleManager::StyleNoDirectoryValid: + { + KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18nc("@inf= o", "Could not find a suitable place to install the Chat Window Style %1.", packageName), errorTitle ); + break; + } + case ChatWindowStyleManager::StyleNotValid: + KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18nc("@inf= o", "The specified archive %1 does not contain a valid= Chat Window Style.", styleFile.pathOrUrl()), errorTitle ); + break; + case ChatWindowStyleManager::StyleInstallOk: + { + ++correctlyInstalled; + break; + } + case ChatWindowStyleManager::StyleUnknow: + default: + { + KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18nc("@inf= o", "An unknown error occurred while trying to install the Chat Window Styl= e %1.", packageName), errorTitle ); + break; + } + } + } + } + + if ( correctlyInstalled > 0) + { + KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18np("On= e Chat Window Style package has been installed.", "%1 Chat Window Style pac= kages have been installed.", correctlyInstalled)); + } + } + delete engine; =2D#endif } =20 void ChatWindowConfig::createPreviewChatSession() @@ -601,7 +584,7 @@ =20 // This is a UTF-8 string btw. Kopete::Message msgRightToLeft( m_myself, m_jack ); =2D msgRightToLeft.setPlainBody( i18nc("This special UTF-8 string is to tes= t if the style support Right-to-Left language display.", "=D7=94=D7=95=D7= =93=D7=A2=D7=95=D7=AA =D7=98=D7=A7=D7=A1=D7=98") ); + msgRightToLeft.setPlainBody( i18nc("This special UTF-8 string is to test = if the style supports Right-to-Left language display.", "=D7=94=D7=95=D7=93= =D7=A2=D7=95=D7=AA =D7=98=D7=A7=D7=A1=D7=98") ); msgRightToLeft.setDirection( Kopete::Message::Outbound ); =20 Kopete::Message msgBye ( m_myself, m_jack ); @@ -719,10 +702,10 @@ =20 QString themeName =3D selected->text(); =20 =2D QString question=3Di18n("Are you sure you want to remove the " =2D "%1 emoticon theme?
" + QString question=3Di18nc("@info", "Are you sure you want to remove the " + "%1 emoticon theme?
" "
" =2D "This will delete the files installed by this theme.
", + "This will delete all files installed by this theme.= ", themeName); =20 int res =3D KMessageBox::warningContinueCancel(this, question, i18= n("Confirmation"),KStandardGuiItem::del()); @@ -737,6 +720,10 @@ =20 void ChatWindowConfig::slotGetEmoticonThemes() { +#ifdef __GNUC__ +#warning "Port KNS changes!" +#endif +#if 0 KConfigGroup config(KGlobal::config(), "KNewStuff"); config.writeEntry( "ProvidersUrl", "http://download.kde.org/khotnewstuff/emoticons-providers.xml" ); @@ -744,14 +731,10 @@ config.writeEntry( "Uncompress", "application/x-gzip" ); config.sync(); =20 =2D#ifdef __GNUC__ =2D#warning "Port KNS changes!" =2D#endif =2D#if 0 KNS::DownloadDialog::open( "emoticons", i18n( "Get New Emoticons") ); =2D#endif =20 updateEmoticonList(); +#endif } =20 =20 --Boundary-01=_AjlAIcoxTdO6kUP-- --nextPart4448063.nXm4DtjKr2 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBIAljGeUsZqsZ5X1kRAiquAJ95W5tlO3zZrSQYSc620Yv63Yp+LwCgixm7 lfKbGsag3/s0Pdpmr+c0s7U= =A9cJ -----END PGP SIGNATURE----- --nextPart4448063.nXm4DtjKr2-- --===============2139410865== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kopete-devel mailing list kopete-devel@kde.org https://mail.kde.org/mailman/listinfo/kopete-devel --===============2139410865==--