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

List:       kopete-devel
Subject:    Re: [kopete-devel] KNewStuff2 port
From:       Dennis_Nienhüser <earthwings () gentoo ! org>
Date:       2007-10-29 19:22:50
Message-ID: 4726330A.9020201 () gentoo ! org
[Download RAW message or body]

Hi all,

results from kdelibs/knewstuff polishing have been merged to trunk,
which means among some bugfixes kns2 now has download progress
indicators and knows about installation status (not fully finished, but
i hope this will change soon).

Attached is a patch for review that integrates kns2 into kopete. Some
feedback on how to do kopete/CMakeLists.txt "properly" (or where to put
the installChatwindowStyle() function) would be nice.

These things still apply:

Dennis Nienhüser schrieb:
> Anyway, here's how it currently works on my local box:
> - kopete_styles.knsrc (in kde config dir) configures the chat window style 
> kns2. Usage of a .knsrc file is enforced by the new API.
> - The KNS2 download dialog is opened upon clicking "Get New Styles" in the 
> Chat Window Configuration dialog.
> - Installation of a style means downloading to share/apps/kopete/styles (KNS2 
> part) and installing the downloaded package via dbus-send
>
> There are some issues, mainly due to unfinished KNS2 stuff:
> - No sync between KNS2 and Kopete installation status

Regards,
Dennis

["kopete-chatwindow-kns2.diff" (text/x-diff)]

Index: kopete/kopetedbusinterface.cpp
===================================================================
--- kopete/kopetedbusinterface.cpp	(Revision 730701)
+++ kopete/kopetedbusinterface.cpp	(Arbeitskopie)
@@ -41,6 +41,7 @@
 
 // Local includes
 #include "kopeteadaptor.h"
+#include "chatwindow/kopetechatwindowstylemanager.h"
 
 QStringList listContact(const QList<Kopete::MetaContact*> &contactList)
 {
@@ -337,4 +338,9 @@
 	}
 }
 
+void KopeteDBusInterface::installChatwindowStyle( const QString &fileUrl )
+{
+	ChatWindowStyleManager::self()->installStyle( fileUrl );
+}
+
 #include "kopetedbusinterface.moc"
Index: kopete/CMakeLists.txt
===================================================================
--- kopete/CMakeLists.txt	(Revision 730701)
+++ kopete/CMakeLists.txt	(Arbeitskopie)
@@ -59,6 +59,8 @@
    kopetewindow.cpp 
    kopeteidentitystatusbaricon.cpp 
    kopetedbusinterface.cpp
+   chatwindow/kopetechatwindowstyle.cpp
+   chatwindow/kopetechatwindowstylemanager.cpp
 #   kimifaceimpl.cpp 
    )
 
Index: kopete/config/chatwindow/kopete_styles.knsrc
===================================================================
--- kopete/config/chatwindow/kopete_styles.knsrc	(Revision 0)
+++ kopete/config/chatwindow/kopete_styles.knsrc	(Revision 0)
@@ -0,0 +1,4 @@
+[KNewStuff2]
+ProvidersUrl=http://download.kde.org/khotnewstuff/kopetestyles12-providers.xml 
+TargetDir=kopete/styles
+InstallationCommand=dbus-send --session --type=method_call --dest='org.kde.kopete' \
                /Kopete org.kde.Kopete.installChatwindowStyle string:%f
Index: kopete/config/chatwindow/CMakeLists.txt
===================================================================
--- kopete/config/chatwindow/CMakeLists.txt	(Revision 730701)
+++ kopete/config/chatwindow/CMakeLists.txt	(Arbeitskopie)
@@ -17,7 +17,7 @@
 kde4_add_plugin(kcm_kopete_chatwindowconfig \
${kcm_kopete_chatwindowconfig_PART_SRCS})  
 
-target_link_libraries(kcm_kopete_chatwindowconfig ${KDE4_KUTILS_LIBS} kopete \
kopetechatwindow_shared ${KDE4_KNEWSTUFF_LIBS} ) \
+target_link_libraries(kcm_kopete_chatwindowconfig ${KDE4_KUTILS_LIBS} kopete \
kopetechatwindow_shared ${KDE4_KNEWSTUFF2_LIBS} )  
 install(TARGETS kcm_kopete_chatwindowconfig DESTINATION ${PLUGIN_INSTALL_DIR})
 
@@ -25,5 +25,4 @@
 ########### install files ###############
 
 install( FILES kopete_chatwindowconfig.desktop  DESTINATION ${SERVICES_INSTALL_DIR})
-
-
+install( FILES kopete_styles.knsrc DESTINATION ${CONFIG_INSTALL_DIR})
Index: kopete/config/chatwindow/chatwindowconfig.cpp
===================================================================
--- kopete/config/chatwindow/chatwindowconfig.cpp	(Revision 730789)
+++ kopete/config/chatwindow/chatwindowconfig.cpp	(Arbeitskopie)
@@ -48,16 +48,7 @@
 #include <krun.h>
 #include <kfiledialog.h>
 
-#ifdef __GNUC__
-#warning "Port KNS changes!"
-#endif
-#if 0
-#include <knewstuff/downloaddialog.h> // knewstuff emoticon and chatwindow fetching
-#include <knewstuff/engine.h>         // "
-#include <knewstuff/entry.h>          // "
-#include <knewstuff/knewstuff.h>      // "
-#include <knewstuff/provider.h>       // "
-#endif
+#include <knewstuff2/engine.h>
 
 // For Kopete Chat Window Style configuration and preview.
 #include <kopetechatwindowstylemanager.h>
@@ -142,62 +133,6 @@
 };
 
 
-#ifdef __GNUC__
-#warning "Port KNS changes!"
-#endif
-#if 0
-class KopeteStyleNewStuff : public KNewStuff
-{
-public:
-	KopeteStyleNewStuff(const QString &type, QWidget *parentWidget = 0)
-	 : KNewStuff( type, parentWidget)
-	{}
-
-	bool createUploadFile(const QString &)
-	{
-		return false;
-	}
-
-	bool install(const QString &styleFilename)
-	{
-		int styleInstallReturn = 0;
-		styleInstallReturn = ChatWindowStyleManager::self()->installStyle( styleFilename \
                );
-
-		switch(styleInstallReturn)
-		{
-			case ChatWindowStyleManager::StyleInstallOk:
-			{
-				KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Information, \
i18n("The Chat Window style was successfully installed."), i18n("Install successful") \
                );
-				return true;
-			}
-			case ChatWindowStyleManager::StyleCannotOpen:
-			{
-				KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, \
i18n("The specified archive cannot be opened.\nMake sure that the archive is valid \
                ZIP or TAR archive."), i18n("Cannot open archive") );
-				break;
-			}
-			case ChatWindowStyleManager::StyleNoDirectoryValid:
-			{
-				KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, \
i18n("Could not find a suitable place to install the Chat Window style in user \
                directory."), i18n("Cannot find styles directory") );
-				break;
-			}
-			case ChatWindowStyleManager::StyleNotValid:
-			{
-				KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, \
i18n("The specified archive does not contain a valid Chat Window style."), \
                i18n("Invalid Style") );
-				break;
-			}
-
-			case ChatWindowStyleManager::StyleUnknow:
-			default:
-			{
-				KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, \
i18n("An unknow error occurred while trying to install the Chat Window style."), \
                i18n("Unknow error") );
-				break;
-			}
-		}
-		return false;
-	}
-};
-#endif
-
 ChatWindowConfig::ChatWindowConfig(QWidget *parent, const QStringList &args )
 	: KCModule( KopeteChatWindowConfigFactory::componentData(), parent, args ),
 		m_currentStyle (0L), m_loading(false), m_styleChanged(false),
@@ -455,24 +390,9 @@
 
 void ChatWindowConfig::slotGetChatStyles()
 {
-#ifdef __GNUC__
-#warning "Port KNS changes!"
-#endif
-#if 0
-	// we need this because KNewStuffGeneric's install function isn't clever enough
-	KopeteStyleNewStuff *kopeteNewStuff = new KopeteStyleNewStuff( "kopete/chatstyle", \
                this );
-	KNS::Engine *engine = new KNS::Engine( kopeteNewStuff, "kopete/chatstyle", this );
-	KNS::DownloadDialog *downloadDialog = new KNS::DownloadDialog( engine, this );
-	downloadDialog->setCategory( "kopete/chatstyle" );
-	// you have to do this by hand when providing your own Engine
-	KNS::ProviderLoader *provider = new KNS::ProviderLoader( this );
-	QObject::connect( provider, SIGNAL( providersLoaded(Provider::List*) ), \
                downloadDialog, SLOT( slotProviders (Provider::List *) ) );
-	provider->load( "kopete/chatstyle", \
                "http://download.kde.org/khotnewstuff/kopetestyles12-providers.xml" \
                );
-	downloadDialog->exec();
-	delete downloadDialog;
-	delete kopeteNewStuff;
-	delete engine;
-#endif
+	KNS::Engine *engine = new KNS::Engine();
+	engine->init("kopete_styles.knsrc");
+	engine->downloadDialog();
 }
 
 void ChatWindowConfig::createPreviewChatSession()
Index: kopete/kopetedbusinterface.h
===================================================================
--- kopete/kopetedbusinterface.h	(Revision 730701)
+++ kopete/kopetedbusinterface.h	(Arbeitskopie)
@@ -174,6 +174,12 @@
 	 * @param fileUrl Url of the file to send
 	 */
 	void sendFile( const QString &displayName, const QString &fileUrl );
+
+	/**
+	 * @brief Install a chat window style from a style package
+	 * @param fileUrl Url of the file that contains the chat window style to install
+	 */
+	void installChatwindowStyle( const QString &fileUrl );
 };
 
 #endif
Index: kopete/org.kde.Kopete.xml
===================================================================
--- kopete/org.kde.Kopete.xml	(Revision 730701)
+++ kopete/org.kde.Kopete.xml	(Arbeitskopie)
@@ -86,5 +86,8 @@
       <arg name="displayName" type="s" direction="in"/>
       <arg name="fileUrl" type="s" direction="in"/>
     </method>
+    <method name="installChatwindowStyle">
+      <arg name="fileUrl" type="s" direction="in"/>
+    </method>
   </interface>
 </node>



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


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

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