From ffe996810ad97da6fd7653fce5ea12c2232b7e9a Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sat, 12 Jul 2008 07:35:34 +0000 Subject: [PATCH] * Now MySQL parts of early_announce and conference code work also with latest MySQL++ lib version 3.0.0. git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1036 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- apps/conference/Conference.cpp | 16 +++++++++++++++- apps/conference/Makefile | 3 +++ apps/early_announce/EarlyAnnounce.cpp | 16 +++++++++++++++- apps/early_announce/Makefile | 8 ++++++-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/apps/conference/Conference.cpp b/apps/conference/Conference.cpp index a306e853..4cabfdf7 100644 --- a/apps/conference/Conference.cpp +++ b/apps/conference/Conference.cpp @@ -107,16 +107,26 @@ int get_audio_file(string message, string domain, string language, DBG("Query string <%s>\n", query_string.c_str()); query << query_string; + +#ifdef VERSION2 mysqlpp::Result res = query.store(); +#else + mysqlpp::StoreQueryResult res = query.store(); +#endif mysqlpp::Row row; if (res) { if ((res.num_rows() > 0) && (row = res.at(0))) { FILE *file; - unsigned long length = row.raw_string(0).size(); file = fopen((*audio_file).c_str(), "wb"); +#ifdef VERSION2 + unsigned long length = row.raw_string(0).size(); fwrite(row.at(0).data(), 1, length, file); +#else + mysqlpp::String s = row[0]; + fwrite(s.data(), 1, s.length(), file); +#endif fclose(file); return 1; } else { @@ -179,7 +189,11 @@ int ConferenceFactory::onLoad() try { +#ifdef VERSION2 Connection.set_option(Connection.opt_reconnect, true); +#else + Connection.set_option(new mysqlpp::ReconnectOption(true)); +#endif Connection.connect(mysql_db.c_str(), mysql_server.c_str(), mysql_user.c_str(), mysql_passwd.c_str()); if (!Connection) { diff --git a/apps/conference/Makefile b/apps/conference/Makefile index 650ee36c..3dbf233a 100644 --- a/apps/conference/Makefile +++ b/apps/conference/Makefile @@ -22,6 +22,9 @@ module_cflags = # # in /usr/include/mysql++/row.h. # +# If your MySQL++ version is less than 3.0.0, you must add -DVERSION2 +# to module_flags below. +# #module_ldflags = -lmysqlpp #module_cflags = -DUSE_MYSQL -I/usr/include/mysql++ -I/usr/include/mysql diff --git a/apps/early_announce/EarlyAnnounce.cpp b/apps/early_announce/EarlyAnnounce.cpp index 8a20e790..2accada9 100644 --- a/apps/early_announce/EarlyAnnounce.cpp +++ b/apps/early_announce/EarlyAnnounce.cpp @@ -99,16 +99,26 @@ int get_announce_msg(string application, string message, string user, DBG("Query string <%s>\n", query_string.c_str()); query << query_string; + +#ifdef VERSION2 mysqlpp::Result res = query.store(); +#else + mysqlpp::StoreQueryResult res = query.store(); +#endif mysqlpp::Row row; if (res) { if ((res.num_rows() > 0) && (row = res.at(0))) { FILE *file; - unsigned long length = row.raw_string(0).size(); file = fopen((*audio_file).c_str(), "wb"); +#ifdef VERSION2 + unsigned long length = row.raw_string(0).size(); fwrite(row.at(0).data(), 1, length, file); +#else + mysqlpp::String s = row[0]; + fwrite(s.data(), 1, s.length(), file); +#endif fclose(file); return 1; } else { @@ -200,7 +210,11 @@ int EarlyAnnounceFactory::onLoad() try { +#ifdef VERSION2 Connection.set_option(Connection.opt_reconnect, true); +#else + Connection.set_option(new mysqlpp::ReconnectOption(true)); +#endif Connection.connect(mysql_db.c_str(), mysql_server.c_str(), mysql_user.c_str(), mysql_passwd.c_str()); if (!Connection) { diff --git a/apps/early_announce/Makefile b/apps/early_announce/Makefile index 3854142a..f5857e9f 100644 --- a/apps/early_announce/Makefile +++ b/apps/early_announce/Makefile @@ -5,8 +5,9 @@ module_cflags = # Uncomment last two lines if you want to keep audio in MySQL database. # You must also install MySQL++ development files and libraries -# (http://www.tangentsoft.net/mysql++/). If your MySQL++ version is older -# than 2.2, you must insert +# (http://www.tangentsoft.net/mysql++/). +# +# If your MySQL++ version is older than 2.2, you must insert # # const std::string & raw_string(int i) const # { @@ -15,6 +16,9 @@ module_cflags = # # in /usr/include/mysql++/row.h. # +# If your MySQL++ version is less than 3.0.0, you must add -DVERSION2 +# to module_flags below. +# #module_ldflags = -lmysqlpp #module_cflags = -DUSE_MYSQL -I/usr/include/mysql++ -I/usr/include/mysql