Author: sayer
Date: 2009-03-31 11:24:59 +0200 (Tue, 31 Mar 2009)
New Revision: 1342
Modified:
trunk/apps/conference/Conference.cpp
Log:
making it a little safer using reference
Modified: trunk/apps/conference/Conference.cpp
===================================================================
--- trunk/apps/conference/Conference.cpp 2009-03-30 19:07:07 UTC (rev
1341)
+++ trunk/apps/conference/Conference.cpp 2009-03-31 09:24:59 UTC (rev
1342)
@@ -78,26 +78,26 @@
mysqlpp::Connection ConferenceFactory::Connection(mysqlpp::use_exceptions);
int get_audio_file(string message, string domain, string language,
- string *audio_file)
+ string& audio_file)
{
string query_string;
if (language.empty()) {
if (domain.empty()) {
- *audio_file = string("/tmp/") + APP_NAME + "_" + message + ".wav";
+ audio_file = string("/tmp/") + APP_NAME + "_" + message + ".wav";
query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) + "
where application='" + APP_NAME + "' and message='" + message + "' and
language=''";
} else {
- *audio_file = "/tmp/" + domain + "_" + APP_NAME + "_" +
+ audio_file = "/tmp/" + domain + "_" + APP_NAME + "_" +
message + ".wav";
query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) + "
where application='" + APP_NAME + "' and message='" + message + "' and
domain='" + domain + "' and language=''";
}
} else {
if (domain.empty()) {
- *audio_file = string("/tmp/") + APP_NAME + "_" + message + "_" +
+ audio_file = "/tmp/" APP_NAME "_" + message + "_" +
language + ".wav";
query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) + "
where application='" + APP_NAME + "' and message='" + message + "' and
language='" + language + "'";
} else {
- *audio_file = "/tmp/" + domain + "_" + APP_NAME + "_" +
+ audio_file = "/tmp/" + domain + "_" APP_NAME "_" +
message + "_" + language + ".wav";
query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) + "
where application='" + APP_NAME + "' and message='" + message + "' and
domain='" + domain + "' and language='" + language + "'";
}
@@ -122,7 +122,7 @@
if (res) {
if ((res.num_rows() > 0) && (row = res.at(0))) {
FILE *file;
- file = fopen((*audio_file).c_str(), "wb");
+ 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);
@@ -133,12 +133,12 @@
fclose(file);
return 1;
} else {
- *audio_file = "";
+ audio_file = "";
return 1;
}
} else {
ERROR("Database query error\n");
- *audio_file = "";
+ audio_file = "";
return 0;
}
}
@@ -146,7 +146,7 @@
catch (const mysqlpp::Exception& er) {
// Catch-all for any MySQL++ exceptions
ERROR("MySQL++ error: %s\n", er.what());
- *audio_file = "";
+ audio_file = "";
return 0;
}
}
@@ -216,7 +216,7 @@
return -1;
}
- if (!get_audio_file(LONELY_USER_MSG, "", "", &LonelyUserFile)) {
+ if (!get_audio_file(LONELY_USER_MSG, "", "", LonelyUserFile)) {
return -1;
}
@@ -226,11 +226,11 @@
return -1;
}
- if (!get_audio_file(JOIN_SOUND, "", "", &JoinSound)) {
+ if (!get_audio_file(JOIN_SOUND, "", "", JoinSound)) {
return -1;
}
- if (!get_audio_file(DROP_SOUND, "", "", &DropSound)) {
+ if (!get_audio_file(DROP_SOUND, "", "", DropSound)) {
return -1;
}
@@ -424,12 +424,12 @@
#ifdef USE_MYSQL
/* Get domain/language specific lonely user file from MySQL */
if (get_audio_file(LONELY_USER_MSG, req.domain, language,
- &lonely_user_file) &&
+ lonely_user_file) &&
!lonely_user_file.empty()) {
ConferenceFactory::LonelyUserFile = lonely_user_file;
} else {
if (get_audio_file(LONELY_USER_MSG, "", language,
- &lonely_user_file) &&
+ lonely_user_file) &&
!lonely_user_file.empty()) {
ConferenceFactory::LonelyUserFile = lonely_user_file;
}
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev