soc.2009.transport: 0de21636: Added 'make install' support and added a...

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Tue Jul 21 02:10:39 EDT 2009


-----------------------------------------------------------------
Revision: 0de216368c69a1ceacba708b853b65fbb83170b9
Ancestor: c036ec023ecae09d1bd4f2c454e3884f29b8b72f
Author: hanzz at soc.pidgin.im
Date: 2009-07-21T06:08:56
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/0de216368c69a1ceacba708b853b65fbb83170b9

Modified files:
        CMakeLists.txt cmake_install.cmake main.cpp main.h

ChangeLog: 

Added 'make install' support and added ability to use multiple configuration files with one executable file

-------------- next part --------------
============================================================
--- CMakeLists.txt	3e625764b33ead76ee3151975f4f5b676397b7f9
+++ CMakeLists.txt	8471b8139812f5cf00143fa00197d2976fbfc15d
@@ -140,6 +140,16 @@
 
 target_link_libraries(hiicq ${GLOOX_LIBRARIES} ${MySQLpp_LIBRARY} ${PURPLE_LIBRARY} ${GLIB_LIBRARIES} ${GETTEXTPO_LIBRARY} -export-dynamic)
 
+INSTALL(TARGETS hiicq
+    RUNTIME DESTINATION bin
+    )
+
+INSTALL(FILES
+    ${CMAKE_CURRENT_SOURCE_DIR}/highflyer.cfg
+	DESTINATION /etc/highflyer/
+    )
+
+
 # install(FILES
 # 	${CMAKE_CURRENT_SOURCE_DIR}/data/LICENSE.txt
 # 	${CMAKE_CURRENT_SOURCE_DIR}/data/TRANSLATIONS.txt
============================================================
--- cmake_install.cmake	a9a86e55d32a0126bba19f2d3aebc8a966141f95
+++ cmake_install.cmake	d1753f10529f6d9ba2b89bad569cc55ba56750c1
@@ -32,6 +32,28 @@ ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EX
   SET(CMAKE_INSTALL_SO_NO_EXE "1")
 ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
 
+IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" MATCHES "^(Unspecified)$")
+  IF("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
+    IF(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/hiicq")
+      FILE(RPATH_CHECK
+           FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/hiicq"
+           RPATH "")
+    ENDIF(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/hiicq")
+    FILE(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE EXECUTABLE FILES "/home/hanzz/code/transport/hiicq")
+    IF(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/hiicq")
+      FILE(RPATH_REMOVE
+           FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/hiicq")
+      IF(CMAKE_INSTALL_DO_STRIP)
+        EXECUTE_PROCESS(COMMAND "/usr/bin/strip" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/hiicq")
+      ENDIF(CMAKE_INSTALL_DO_STRIP)
+    ENDIF(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/hiicq")
+  ENDIF("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
+ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" MATCHES "^(Unspecified)$")
+
+IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" MATCHES "^(Unspecified)$")
+  FILE(INSTALL DESTINATION "/etc/highflyer" TYPE FILE FILES "/home/hanzz/code/transport/highflyer.cfg")
+ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" MATCHES "^(Unspecified)$")
+
 IF(CMAKE_INSTALL_COMPONENT)
   SET(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
 ELSE(CMAKE_INSTALL_COMPONENT)
============================================================
--- main.cpp	fa32f806c1d5560a8dc7c5dbd68560fc684d12e0
+++ main.cpp	fd8f158a1e2be8c5ab7b6f211cbde2bfa84a5657
@@ -566,13 +566,13 @@ static gboolean iter(GIOChannel *source,
 	return TRUE;
 }
 
-GlooxMessageHandler::GlooxMessageHandler() : MessageHandler(),ConnectionListener(),PresenceHandler(),SubscriptionHandler() {
+GlooxMessageHandler::GlooxMessageHandler(const std::string &config) : MessageHandler(),ConnectionListener(),PresenceHandler(),SubscriptionHandler() {
 	m_pInstance = this;
 	m_firstConnection = true;
 	lastIP=0;
 	capsCache["_default"]=0;
 	
-	loadConfigFile();
+	loadConfigFile(config);
 	
 	Log().Get("gloox") << "connecting to: " << m_configuration.server << " as " << m_configuration.jid << " with password " << m_configuration.password;
 	j = new HiComponent("jabber:component:accept",m_configuration.server,m_configuration.jid,m_configuration.password,m_configuration.port);
@@ -796,7 +796,7 @@ void * GlooxMessageHandler::purpleAuthor
 /*
  * Load config file and parses it and save result to m_configuration
  */
-void GlooxMessageHandler::loadConfigFile(){
+void GlooxMessageHandler::loadConfigFile(const std::string &config){
 	GKeyFile *keyfile;
 	int flags;
 	GError *error = NULL;
@@ -806,10 +806,10 @@ void GlooxMessageHandler::loadConfigFile
 	keyfile = g_key_file_new ();
 	flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
 	
-	if (!g_key_file_load_from_file (keyfile, "highflyer.cfg", (GKeyFileFlags)flags, &error))
+	if (!g_key_file_load_from_file (keyfile, std::string("/etc/highflyer/" + config + ".cfg").c_str(), (GKeyFileFlags)flags, &error))
 	{
 // 		g_error (error->message);
-		Log().Get("gloox") << "Can't load highflyer.cfg!!!";
+		Log().Get("gloox") << "Can't load config file!!!";
 		g_key_file_free(keyfile);
 		return;
 	}
@@ -1425,6 +1425,11 @@ int main( int argc, char* argv[] ) {
 
 GlooxMessageHandler* GlooxMessageHandler::m_pInstance = NULL;
 int main( int argc, char* argv[] ) {
-	GlooxMessageHandler t;
+	if (argc != 2)
+		std::cout << "Usage: " << std::string(argv[1]) << " config_file_name\n";
+	else {
+		std::string config(argv[1]);
+		GlooxMessageHandler t(config);
+	}
 }
 
============================================================
--- main.h	9f930ab61833348511a12c77de747b19d0e8c9e3
+++ main.h	f33eea62e4ee4c6386d8f879f01e3a720fbfafa6
@@ -152,7 +152,7 @@ public:
 {
 
 public:
-	GlooxMessageHandler();
+	GlooxMessageHandler(const std::string &config);
 	~GlooxMessageHandler();
 	
 	static GlooxMessageHandler *instance() { return m_pInstance; }
@@ -222,7 +222,7 @@ private:
 private:
 // 	bool callback(GIOCondition condition);
 	bool initPurple();
-	void loadConfigFile();
+	void loadConfigFile(const std::string &config);
 	void loadProtocol();
 	
 	Configuration m_configuration;


More information about the Commits mailing list