← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3092: start sketching a UI plugin interface

 

------------------------------------------------------------
revno: 3092
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2012-10-27 18:10:35 +0200
message:
  start sketching a UI plugin interface
added:
  win32/PluginApiImpl.cpp
modified:
  dcpp/PluginApiImpl.cpp
  dcpp/PluginApiImpl.h
  dcpp/PluginDefs.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/PluginApiImpl.cpp'
--- dcpp/PluginApiImpl.cpp	2012-09-08 13:54:40 +0000
+++ dcpp/PluginApiImpl.cpp	2012-10-27 16:10:35 +0000
@@ -74,7 +74,6 @@
 
 static const char* hostName = APPNAME;
 
-// lambdas are not used because certain compiler is being a pain about it (for now)
 DCHooks PluginApiImpl::dcHooks = {
 	DCINTF_HOOKS_VER,
 
@@ -167,6 +166,12 @@
 	&PluginApiImpl::addTag
 };
 
+DCUI PluginApiImpl::dcUI = {
+	DCINTF_DCPP_UI_VER,
+
+	&PluginApiImpl::playSound
+};
+
 Socket* PluginApiImpl::udpSocket = nullptr;
 Socket& PluginApiImpl::getUdpSocket() {
 	if(!udpSocket) {
@@ -197,6 +202,7 @@
 	dcCore.register_interface(DCINTF_DCPP_QUEUE, &dcQueue);
 	dcCore.register_interface(DCINTF_DCPP_UTILS, &dcUtils);
 	dcCore.register_interface(DCINTF_DCPP_TAGGER, &dcTagger);
+	dcCore.register_interface(DCINTF_DCPP_UI, &dcUI);
 
 	// Create provided hooks (since these outlast any plugin they don't need to be explictly released)
 	for(int i = 0; i < IMPL_HOOKS_COUNT; ++i)

=== modified file 'dcpp/PluginApiImpl.h'
--- dcpp/PluginApiImpl.h	2012-09-08 13:54:40 +0000
+++ dcpp/PluginApiImpl.h	2012-10-27 16:10:35 +0000
@@ -93,6 +93,9 @@
 	// Functions for DCTagger
 	static void DCAPI addTag(TagDataPtr hTags, size_t start, size_t end, const char* id, const char* attributes);
 
+	// Functions for DCUI - the host has to define these
+	static void DCAPI playSound(const char* path);
+
 	// Functions for DCQueue
 	static QueueDataPtr DCAPI addList(UserDataPtr user, Bool silent);
 	static QueueDataPtr DCAPI addDownload(const char* hash, uint64_t size, const char* target);
@@ -124,6 +127,7 @@
 	static DCQueue dcQueue;
 	static DCUtils dcUtils;
 	static DCTagger dcTagger;
+	static DCUI dcUI;
 
 	static Socket* udpSocket;
 	static Socket& getUdpSocket();

=== modified file 'dcpp/PluginDefs.h'
--- dcpp/PluginDefs.h	2012-09-09 14:31:02 +0000
+++ dcpp/PluginDefs.h	2012-10-27 16:10:35 +0000
@@ -68,9 +68,12 @@
 #define DCINTF_DCPP_UTILS			"dcpp.utils.DCUtils"		/* Utility and convenience functions */
 #define DCINTF_DCPP_UTILS_VER		1
 
-#define DCINTF_DCPP_TAGGER			"dcpp.xml.Tagger"			/* Manipulation of an XML tagger */
+#define DCINTF_DCPP_TAGGER			"dcpp.xml.DCTagger"			/* Manipulation of an XML tagger */
 #define DCINTF_DCPP_TAGGER_VER		1
 
+#define DCINTF_DCPP_UI				"dcpp.ui.DCUI"				/* User interface */
+#define DCINTF_DCPP_UI_VER			1
+
 /* Hook GUID's for Hooks (events) system */
 #define HOOK_CHAT_IN				"dcpp.chat.onIncomingChat"	/* Incoming chat from hub (obj: HubData) */
 #define HOOK_CHAT_OUT				"dcpp.chat.onOutgoingChat"	/* Outgoing chat (obj: HubData) */
@@ -412,6 +415,14 @@
 	void		(DCAPI *add_tag)					(TagDataPtr hTags, size_t start, size_t end, const char* id, const char* attributes);
 } DCTagger, *DCTaggerPtr;
 
+/* User interface */
+typedef struct DCUI {
+	/* User interface API version */
+	uint32_t apiVersion;
+
+	void		(DCAPI *play_sound)					(const char* path);
+} DCUI, *DCUIPtr;
+
 #ifdef __cplusplus
 }
 #endif

=== added file 'win32/PluginApiImpl.cpp'
--- win32/PluginApiImpl.cpp	1970-01-01 00:00:00 +0000
+++ win32/PluginApiImpl.cpp	2012-10-27 16:10:35 +0000
@@ -0,0 +1,36 @@
+/* 
+ * Copyright (C) 2001-2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/** @file implement UI-specific functions of the plugin API. */
+
+#include "stdafx.h"
+
+#include <dcpp/PluginApiImpl.h>
+
+#include <dcpp/Text.h>
+
+#include "WinUtil.h"
+
+namespace dcpp {
+
+// Functions for DCUI
+void PluginApiImpl::playSound(const char* path) {
+	WinUtil::playSound(Text::toT(path));
+}
+
+} // namespace dcpp