Author: sayer
Date: 2009-10-14 16:00:53 +0200 (Wed, 14 Oct 2009)
New Revision: 1542
Modified:
trunk/apps/dsm/DSMModule.h
trunk/apps/dsm/mods/mod_aws/ModAws.cpp
trunk/apps/dsm/mods/mod_aws/ModAws.h
trunk/apps/dsm/mods/mod_conference/ModConference.cpp
trunk/apps/dsm/mods/mod_conference/ModConference.h
trunk/apps/dsm/mods/mod_dlg/ModDlg.cpp
trunk/apps/dsm/mods/mod_dlg/ModDlg.h
trunk/apps/dsm/mods/mod_py/ModPy.cpp
trunk/apps/dsm/mods/mod_py/ModPy.h
trunk/apps/dsm/mods/mod_sys/ModSys.cpp
trunk/apps/dsm/mods/mod_sys/ModSys.h
trunk/apps/dsm/mods/mod_uri/ModUri.cpp
trunk/apps/dsm/mods/mod_uri/ModUri.h
trunk/apps/dsm/mods/mod_utils/ModUtils.cpp
trunk/apps/dsm/mods/mod_utils/ModUtils.h
Log:
went one step further with macrotisation of DSM modules
Modified: trunk/apps/dsm/DSMModule.h
===================================================================
--- trunk/apps/dsm/DSMModule.h 2009-10-14 12:00:58 UTC (rev 1541)
+++ trunk/apps/dsm/DSMModule.h 2009-10-14 14:00:53 UTC (rev 1542)
@@ -267,4 +267,60 @@
return false; \
}
+
+#define DECLARE_MODULE(mod_cls_name) \
+ class mod_cls_name \
+ : public DSMModule { \
+ \
+ public: \
+ mod_cls_name() { } \
+ ~mod_cls_name() { } \
+ \
+ DSMAction* getAction(const string& from_str); \
+ DSMCondition* getCondition(const string& from_str); \
+};
+
+#define DECLARE_MODULE_BEGIN(mod_cls_name) \
+ class mod_cls_name \
+ : public DSMModule { \
+ \
+ public: \
+ mod_cls_name() { } \
+ ~mod_cls_name() { } \
+ \
+ DSMAction* getAction(const string& from_str); \
+ DSMCondition* getCondition(const string& from_str);
+
+
+
+#define DECLARE_MODULE_END \
+ }
+
+#define MOD_ACTIONEXPORT_BEGIN(mod_cls_name) \
+ DSMAction* mod_cls_name::getAction(const string& from_str) { \
+ string cmd; \
+ string params; \
+ splitCmd(from_str, cmd, params);
+
+#define MOD_ACTIONEXPORT_END \
+ return NULL; \
+ }
+
+#define MOD_CONDITIONEXPORT_NONE(mod_cls_name) \
+ DSMCondition* mod_cls_name::getCondition(const string& from_str) { \
+ return NULL; \
+ }
+
+
+#define MOD_CONDITIONEXPORT_BEGIN(mod_cls_name)
\
+ DSMCondition* mod_cls_name::getCondition(const string& from_str) { \
+ string cmd; \
+ string params; \
+ splitCmd(from_str, cmd, params);
+
+#define MOD_CONDITIONEXPORT_END \
+ return NULL; \
+ } \
+
+
#endif
Modified: trunk/apps/dsm/mods/mod_aws/ModAws.cpp
===================================================================
--- trunk/apps/dsm/mods/mod_aws/ModAws.cpp 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_aws/ModAws.cpp 2009-10-14 14:00:53 UTC (rev
1542)
@@ -36,22 +36,13 @@
#include <fstream>
-SC_EXPORT(SCAwsModule);
+SC_EXPORT(MOD_CLS_NAME);
ConnectionPool<S3ConnectionPtr>* SCAwsModule::s3ConnectionPool = NULL;
ConnectionPool<SQSConnectionPtr>* SCAwsModule::sqsConnectionPool = NULL;
-SCAwsModule::SCAwsModule() {
-}
+MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
-SCAwsModule::~SCAwsModule() {
-}
-
-DSMAction* SCAwsModule::getAction(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
-
DEF_CMD("aws.s3.put", SCS3PutFileAction);
DEF_CMD("aws.s3.putArray", SCS3PutMultiFileAction);
DEF_CMD("aws.s3.createBucket", SCS3CreateBucketAction);
@@ -62,23 +53,10 @@
DEF_CMD("aws.sqs.receiveMessage", SCSQSReceiveMessageAction);
DEF_CMD("aws.sqs.deleteMessage", SCSQSDeleteMessageAction);
- return NULL;
-}
+} MOD_ACTIONEXPORT_END;
-DSMCondition* SCAwsModule::getCondition(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
+MOD_CONDITIONEXPORT_NONE(MOD_CLS_NAME);
-// if (cmd == "mysql.hasResult") {
-// return new MyHasResultCondition(params, false);
-// }
-
-
- return NULL;
-}
-
-
int SCAwsModule::preload() {
AmConfigReader cfg;
if(cfg.loadFile(AmConfig::ModConfigPath + string("aws.conf")))
Modified: trunk/apps/dsm/mods/mod_aws/ModAws.h
===================================================================
--- trunk/apps/dsm/mods/mod_aws/ModAws.h 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_aws/ModAws.h 2009-10-14 14:00:53 UTC (rev
1542)
@@ -38,21 +38,26 @@
#define DSM_ERRNO_AWS_DELETE "53"
#define DSM_ERRNO_AWS_SEND "54"
-class SCAwsModule
-: public DSMModule {
+#define MOD_CLS_NAME SCAwsModule
- public:
- SCAwsModule();
- ~SCAwsModule();
+DECLARE_MODULE_BEGIN(MOD_CLS_NAME);
+
+/* class SCAwsModule */
+/* : public DSMModule { */
+
+/* public: */
+/* SCAwsModule(); */
+/* ~SCAwsModule(); */
- DSMAction* getAction(const string& from_str);
- DSMCondition* getCondition(const string& from_str);
+/* DSMAction* getAction(const string& from_str); */
+/* DSMCondition* getCondition(const string& from_str); */
int preload();
static ConnectionPool<S3ConnectionPtr>* s3ConnectionPool;
static ConnectionPool<SQSConnectionPtr>* sqsConnectionPool;
-};
+DECLARE_MODULE_END;
+/* }; */
DEF_ACTION_1P(SCS3CreateBucketAction);
Modified: trunk/apps/dsm/mods/mod_conference/ModConference.cpp
===================================================================
--- trunk/apps/dsm/mods/mod_conference/ModConference.cpp 2009-10-14
12:00:58 UTC (rev 1541)
+++ trunk/apps/dsm/mods/mod_conference/ModConference.cpp 2009-10-14
14:00:53 UTC (rev 1542)
@@ -34,64 +34,20 @@
#include "DSMSession.h"
#include "ModConference.h"
-SC_EXPORT(ConfModule);
+SC_EXPORT(MOD_CLS_NAME);
-ConfModule::ConfModule() {
-}
+MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
-ConfModule::~ConfModule() {
-}
-
-void splitCmd(const string& from_str,
- string& cmd, string& params) {
- size_t b_pos = from_str.find('(');
- if (b_pos != string::npos) {
- cmd = from_str.substr(0, b_pos);
- params = from_str.substr(b_pos + 1, from_str.rfind(')') - b_pos -1);
- } else
- cmd = from_str;
-}
-
-DSMAction* ConfModule::getAction(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
-
-#define DEF_CMD(cmd_name, class_name) \
- \
- if (cmd == cmd_name) { \
- class_name * a = \
- new class_name(params); \
- a->name = from_str; \
- return a; \
- }
-
DEF_CMD("conference.join", ConfJoinAction);
DEF_CMD("conference.postEvent", ConfPostEventAction);
DEF_CMD("conference.setPlayoutType", ConfSetPlayoutTypeAction);
- return NULL;
-}
+} MOD_ACTIONEXPORT_END;
-DSMCondition* ConfModule::getCondition(const string& from_str) {
- return NULL;
-}
+MOD_CONDITIONEXPORT_NONE(MOD_CLS_NAME);
-#define GET_SCSESSION() \
- DSMSession* sc_sess = dynamic_cast<DSMSession*>(sess); \
- if (!sc_sess) { \
- ERROR("wrong session type\n"); \
- return false; \
- }
-
-
CONST_ACTION_2P(ConfPostEventAction, ',', true);
-
-bool ConfPostEventAction::execute(AmSession* sess,
- DSMCondition::EventType event,
- map<string,string>* event_params) {
- GET_SCSESSION();
-
+EXEC_ACTION_START(ConfPostEventAction) {
string channel_id = resolveVars(par1, sess, sc_sess, event_params);
string ev_id = resolveVars(par2, sess, sc_sess, event_params);
@@ -102,17 +58,11 @@
}
AmConferenceStatus::postConferenceEvent(channel_id, ev, sess->getLocalTag());
+} EXEC_ACTION_END;
- return false;
-}
-
CONST_ACTION_2P(ConfJoinAction, ',', true);
-bool ConfJoinAction::execute(AmSession* sess,
- DSMCondition::EventType event,
- map<string,string>* event_params) {
- GET_SCSESSION();
-
+EXEC_ACTION_START(ConfJoinAction) {
string channel_id = resolveVars(par1, sess, sc_sess, event_params);
string mode = resolveVars(par2, sess, sc_sess, event_params);
@@ -147,16 +97,10 @@
sc_sess->addToPlaylist(new AmPlaylistItem(play_item, rec_item));
sc_sess->transferOwnership(dsm_chan);
+} EXEC_ACTION_END;
- return false;
-}
-
-bool ConfSetPlayoutTypeAction::execute(AmSession* sess,
- DSMCondition::EventType event,
- map<string,string>* event_params) {
- GET_SCSESSION();
-
+EXEC_ACTION_START(ConfSetPlayoutTypeAction) {
string playout_type = resolveVars(arg, sess, sc_sess, event_params);
if (playout_type == "adaptive")
sess->rtp_str.setPlayoutType(ADAPTIVE_PLAYOUT);
@@ -164,6 +108,4 @@
sess->rtp_str.setPlayoutType(JB_PLAYOUT);
else
sess->rtp_str.setPlayoutType(SIMPLE_PLAYOUT);
-
- return false;
-}
+} EXEC_ACTION_END;
Modified: trunk/apps/dsm/mods/mod_conference/ModConference.h
===================================================================
--- trunk/apps/dsm/mods/mod_conference/ModConference.h 2009-10-14 12:00:58 UTC
(rev 1541)
+++ trunk/apps/dsm/mods/mod_conference/ModConference.h 2009-10-14 14:00:53 UTC
(rev 1542)
@@ -31,18 +31,10 @@
#include "DSMSession.h"
#include <memory>
+#define MOD_CLS_NAME ConfModule
-class ConfModule
-: public DSMModule {
+DECLARE_MODULE(MOD_CLS_NAME);
- public:
- ConfModule();
- ~ConfModule();
-
- DSMAction* getAction(const string& from_str);
- DSMCondition* getCondition(const string& from_str);
-};
-
class DSMConfChannel : public DSMDisposable {
std::auto_ptr<AmConferenceChannel> chan;
@@ -54,4 +46,5 @@
DEF_ACTION_2P(ConfJoinAction);
DEF_ACTION_2P(ConfPostEventAction);
DEF_ACTION_1P(ConfSetPlayoutTypeAction);
+
#endif
Modified: trunk/apps/dsm/mods/mod_dlg/ModDlg.cpp
===================================================================
--- trunk/apps/dsm/mods/mod_dlg/ModDlg.cpp 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_dlg/ModDlg.cpp 2009-10-14 14:00:53 UTC (rev
1542)
@@ -34,53 +34,24 @@
#include <string.h>
#include "AmSipHeaders.h"
-SC_EXPORT(DLGModule);
+SC_EXPORT(MOD_CLS_NAME);
-DLGModule::DLGModule() {
-}
-DLGModule::~DLGModule() {
-}
+MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
-void splitCmd(const string& from_str,
- string& cmd, string& params) {
- size_t b_pos = from_str.find('(');
- if (b_pos != string::npos) {
- cmd = from_str.substr(0, b_pos);
- params = from_str.substr(b_pos + 1, from_str.rfind(')') - b_pos -1);
- } else
- cmd = from_str;
-}
-
-DSMAction* DLGModule::getAction(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
-
-#define DEF_CMD(cmd_name, class_name) \
- \
- if (cmd == cmd_name) { \
- class_name * a = \
- new class_name(params); \
- a->name = from_str; \
- return a; \
- }
-
DEF_CMD("dlg.reply", DLGReplyAction);
DEF_CMD("dlg.acceptInvite", DLGAcceptInviteAction);
DEF_CMD("dlg.bye", DLGByeAction);
DEF_CMD("dlg.connectCalleeRelayed", DLGConnectCalleeRelayedAction);
- return NULL;
-}
+} MOD_ACTIONEXPORT_END;
-DSMCondition* DLGModule::getCondition(const string& from_str) {
- return NULL;
-}
+MOD_CONDITIONEXPORT_NONE(MOD_CLS_NAME);
bool DLGModule::onInvite(const AmSipRequest& req, DSMSession* sess) {
// save inivital invite to last_req
- sess->last_req.reset(new AmSipRequest(req));
+ // todo: save this in avar
+ sess->last_req.reset(new AmSipRequest(req));
return true;
}
@@ -92,12 +63,7 @@
}
CONST_ACTION_2P(DLGReplyAction, ',', true);
-
-bool DLGReplyAction::execute(AmSession* sess,
- DSMCondition::EventType event,
- map<string,string>* event_params) {
- GET_SCSESSION();
-
+EXEC_ACTION_START(DLGReplyAction) {
string code = resolveVars(par1, sess, sc_sess, event_params);
string reason = resolveVars(par2, sess, sc_sess, event_params);
unsigned int code_i;
@@ -117,17 +83,10 @@
sc_sess->SET_ERRNO(DSM_ERRNO_GENERAL);
else
sc_sess->SET_ERRNO(DSM_ERRNO_OK);
+} EXEC_ACTION_END;
- return false;
-}
-
CONST_ACTION_2P(DLGAcceptInviteAction, ',', true);
-
-bool DLGAcceptInviteAction::execute(AmSession* sess,
- DSMCondition::EventType event,
- map<string,string>* event_params) {
- GET_SCSESSION();
-
+EXEC_ACTION_START(DLGAcceptInviteAction) {
// defaults to 200 OK
unsigned int code_i=200;
string reason = "OK";
@@ -163,10 +122,8 @@
sess->setStopped();
AmSipDialog::reply_error(*sc_sess->last_req.get(),e.code,e.reason);
}
+} EXEC_ACTION_END;
- return false;
-}
-
EXEC_ACTION_START(DLGByeAction) {
string hdrs = resolveVars(arg, sess, sc_sess, event_params);
@@ -194,5 +151,4 @@
ERROR("getting B2B session.\n");
sc_sess->B2BconnectCallee(remote_party, remote_uri, true);
-
} EXEC_ACTION_END;
Modified: trunk/apps/dsm/mods/mod_dlg/ModDlg.h
===================================================================
--- trunk/apps/dsm/mods/mod_dlg/ModDlg.h 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_dlg/ModDlg.h 2009-10-14 14:00:53 UTC (rev
1542)
@@ -28,19 +28,12 @@
#define _MOD_DLG_H
#include "DSMModule.h"
-class DLGModule
-: public DSMModule {
+#define MOD_CLS_NAME DLGModule
- public:
- DLGModule();
- ~DLGModule();
-
- DSMAction* getAction(const string& from_str);
- DSMCondition* getCondition(const string& from_str);
+DECLARE_MODULE_BEGIN(MOD_CLS_NAME);
+bool onInvite(const AmSipRequest& req, DSMSession* sess);
+DECLARE_MODULE_END;
- bool onInvite(const AmSipRequest& req, DSMSession* sess);
-};
-
DEF_ACTION_2P(DLGReplyAction);
DEF_ACTION_2P(DLGAcceptInviteAction);
DEF_ACTION_2P(DLGConnectCalleeRelayedAction);
Modified: trunk/apps/dsm/mods/mod_py/ModPy.cpp
===================================================================
--- trunk/apps/dsm/mods/mod_py/ModPy.cpp 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_py/ModPy.cpp 2009-10-14 14:00:53 UTC (rev
1542)
@@ -95,10 +95,7 @@
return 0;
}
-DSMAction* SCPyModule::getAction(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
+MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
if (NULL==dsm_module) {
ERROR("mod_py must be preloaded! add preload=mod_py to dsm.conf\n");
@@ -112,14 +109,11 @@
return NULL;
}
- return NULL;
-}
+} MOD_ACTIONEXPORT_END;
-DSMCondition* SCPyModule::getCondition(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
+MOD_CONDITIONEXPORT_BEGIN(MOD_CLS_NAME) {
+
if (NULL==dsm_module) {
ERROR("mod_py must be preloaded! add preload=mod_py to dsm.conf\n");
return NULL;
@@ -134,8 +128,7 @@
}
}
- return NULL;
-}
+} MOD_CONDITIONEXPORT_END;
SCPyDictArg::SCPyDictArg()
: pPyObject(NULL) {
@@ -316,7 +309,7 @@
/* Disable signal handling */
PyOS_FiniInterrupts();
- PyInterpreterState_Clear(interp);
+ PyInterpreterState_Clear(interp);
/* Delete current thread */
Modified: trunk/apps/dsm/mods/mod_py/ModPy.h
===================================================================
--- trunk/apps/dsm/mods/mod_py/ModPy.h 2009-10-14 12:00:58 UTC (rev 1541)
+++ trunk/apps/dsm/mods/mod_py/ModPy.h 2009-10-14 14:00:53 UTC (rev 1542)
@@ -31,8 +31,9 @@
#include <Python.h>
+#define MOD_CLS_NAME SCPyModule
-class SCPyModule
+class SCPyModule
: public DSMModule {
public:
Modified: trunk/apps/dsm/mods/mod_sys/ModSys.cpp
===================================================================
--- trunk/apps/dsm/mods/mod_sys/ModSys.cpp 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_sys/ModSys.cpp 2009-10-14 14:00:53 UTC (rev
1542)
@@ -35,29 +35,10 @@
#include <sys/types.h>
#include <stdio.h>
-SC_EXPORT(SCSysModule);
+SC_EXPORT(MOD_CLS_NAME);
-SCSysModule::SCSysModule() {
-}
+MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
-SCSysModule::~SCSysModule() {
-}
-
-void splitCmd(const string& from_str,
- string& cmd, string& params) {
- size_t b_pos = from_str.find('(');
- if (b_pos != string::npos) {
- cmd = from_str.substr(0, b_pos);
- params = from_str.substr(b_pos + 1, from_str.rfind(')') - b_pos -1);
- } else
- cmd = from_str;
-}
-
-DSMAction* SCSysModule::getAction(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
-
DEF_CMD("sys.mkdir", SCMkDirAction);
DEF_CMD("sys.mkdirRecursive", SCMkDirRecursiveAction);
DEF_CMD("sys.rename", SCRenameAction);
@@ -65,13 +46,9 @@
DEF_CMD("sys.unlinkArray", SCUnlinkArrayAction);
DEF_CMD("sys.tmpnam", SCTmpNamAction);
- return NULL;
-}
+} MOD_ACTIONEXPORT_END;
-DSMCondition* SCSysModule::getCondition(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
+MOD_CONDITIONEXPORT_BEGIN(MOD_CLS_NAME) {
if (cmd == "sys.file_exists") {
return new FileExistsCondition(params, false);
@@ -82,8 +59,7 @@
return new FileExistsCondition(params, true);
}
- return NULL;
-}
+} MOD_CONDITIONEXPORT_END;
MATCH_CONDITION_START(FileExistsCondition) {
DBG("checking file '%s'\n", arg.c_str());
Modified: trunk/apps/dsm/mods/mod_sys/ModSys.h
===================================================================
--- trunk/apps/dsm/mods/mod_sys/ModSys.h 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_sys/ModSys.h 2009-10-14 14:00:53 UTC (rev
1542)
@@ -28,16 +28,9 @@
#define _MOD_SYS_H
#include "DSMModule.h"
-class SCSysModule
-: public DSMModule {
+#define MOD_CLS_NAME SCSysModule
- public:
- SCSysModule();
- ~SCSysModule();
-
- DSMAction* getAction(const string& from_str);
- DSMCondition* getCondition(const string& from_str);
-};
+DECLARE_MODULE(MOD_CLS_NAME);
DEF_SCCondition(FileExistsCondition);
DEF_ACTION_1P(SCMkDirAction);
Modified: trunk/apps/dsm/mods/mod_uri/ModUri.cpp
===================================================================
--- trunk/apps/dsm/mods/mod_uri/ModUri.cpp 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_uri/ModUri.cpp 2009-10-14 14:00:53 UTC (rev
1542)
@@ -36,62 +36,25 @@
#include "AmUriParser.h"
-SC_EXPORT(URIModule);
+SC_EXPORT(MOD_CLS_NAME);
-URIModule::URIModule() {
-}
+MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
-URIModule::~URIModule() {
-}
-
-void splitCmd(const string& from_str,
- string& cmd, string& params) {
- size_t b_pos = from_str.find('(');
- if (b_pos != string::npos) {
- cmd = from_str.substr(0, b_pos);
- params = from_str.substr(b_pos + 1, from_str.rfind(')') - b_pos -1);
- } else
- cmd = from_str;
-}
-
-DSMAction* URIModule::getAction(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
-
-#define DEF_CMD(cmd_name, class_name) \
- \
- if (cmd == cmd_name) { \
- class_name * a = \
- new class_name(params); \
- a->name = from_str; \
- return a; \
- }
-
DEF_CMD("uri.parse", URIParseAction);
DEF_CMD("uri.getHeader", URIGetHeaderAction);
- return NULL;
-}
+} MOD_ACTIONEXPORT_END;
-DSMCondition* URIModule::getCondition(const string& from_str) {
- return NULL;
+MOD_CONDITIONEXPORT_NONE(MOD_CLS_NAME);
+
+bool URIModule::onInvite(const AmSipRequest& req, DSMSession* sess) {
+ sess->var["hdrs"] = req.hdrs;
+ return true;
}
-#define GET_SCSESSION() \
- DSMSession* sc_sess = dynamic_cast<DSMSession*>(sess); \
- if (!sc_sess) { \
- ERROR("wrong session type\n"); \
- return false; \
- }
-
CONST_ACTION_2P(URIParseAction, ',', true);
+EXEC_ACTION_START(URIParseAction) {
-bool URIParseAction::execute(AmSession* sess,
- DSMCondition::EventType event,
- map<string,string>* event_params) {
- GET_SCSESSION();
-
string uri = resolveVars(par1, sess, sc_sess, event_params);
string prefix = resolveVars(par2, sess, sc_sess, event_params);
@@ -107,24 +70,14 @@
sc_sess->var[prefix+"host"] = p.uri_host;
sc_sess->var[prefix+"param"] = p.uri_param;
- return false;
-}
+} EXEC_ACTION_END;
-bool URIModule::onInvite(const AmSipRequest& req, DSMSession* sess) {
- sess->var["hdrs"] = req.hdrs;
- return true;
-}
-
CONST_ACTION_2P(URIGetHeaderAction, ',', false);
-bool URIGetHeaderAction::execute(AmSession* sess,
- DSMCondition::EventType event,
- map<string,string>* event_params) {
- GET_SCSESSION();
+EXEC_ACTION_START(URIGetHeaderAction) {
string hname = resolveVars(par1, sess, sc_sess, event_params);
string dstname = resolveVars(par2, sess, sc_sess, event_params);
sc_sess->var[dstname] = getHeader(sc_sess->var["hdrs"], hname); DBG("got
header '%s' value '%s' as $%s\n",
hname.c_str(), sc_sess->var[dstname].c_str(), dstname.c_str());
- return false;
-}
+} EXEC_ACTION_END;
Modified: trunk/apps/dsm/mods/mod_uri/ModUri.h
===================================================================
--- trunk/apps/dsm/mods/mod_uri/ModUri.h 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_uri/ModUri.h 2009-10-14 14:00:53 UTC (rev
1542)
@@ -28,19 +28,12 @@
#define _MOD_SYS_H
#include "DSMModule.h"
-class URIModule
-: public DSMModule {
+#define MOD_CLS_NAME URIModule
- public:
- URIModule();
- ~URIModule();
-
- DSMAction* getAction(const string& from_str);
- DSMCondition* getCondition(const string& from_str);
+DECLARE_MODULE_BEGIN(MOD_CLS_NAME);
+bool onInvite(const AmSipRequest& req, DSMSession* sess);
+DECLARE_MODULE_END;
- bool onInvite(const AmSipRequest& req, DSMSession* sess);
-};
-
DEF_ACTION_2P(URIParseAction);
DEF_ACTION_2P(URIGetHeaderAction);
Modified: trunk/apps/dsm/mods/mod_utils/ModUtils.cpp
===================================================================
--- trunk/apps/dsm/mods/mod_utils/ModUtils.cpp 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_utils/ModUtils.cpp 2009-10-14 14:00:53 UTC (rev
1542)
@@ -34,29 +34,10 @@
#include "DSMSession.h"
#include "AmSession.h"
-SC_EXPORT(SCUtilsModule);
+SC_EXPORT(MOD_CLS_NAME);
-SCUtilsModule::SCUtilsModule() {
-}
+MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
-SCUtilsModule::~SCUtilsModule() {
-}
-
-void splitCmd(const string& from_str,
- string& cmd, string& params) {
- size_t b_pos = from_str.find('(');
- if (b_pos != string::npos) {
- cmd = from_str.substr(0, b_pos);
- params = from_str.substr(b_pos + 1, from_str.rfind(')') - b_pos -1);
- } else
- cmd = from_str;
-}
-
-DSMAction* SCUtilsModule::getAction(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
-
DEF_CMD("utils.playCountRight", SCUPlayCountRightAction);
DEF_CMD("utils.playCountLeft", SCUPlayCountLeftAction);
DEF_CMD("utils.getNewId", SCGetNewIdAction);
@@ -64,16 +45,10 @@
DEF_CMD("utils.rand", SCURandomAction);
DEF_CMD("utils.srand", SCUSRandomAction);
- return NULL;
-}
-DSMCondition* SCUtilsModule::getCondition(const string& from_str) {
- string cmd;
- string params;
- splitCmd(from_str, cmd, params);
+} MOD_ACTIONEXPORT_END;
- return NULL;
-}
+MOD_CONDITIONEXPORT_NONE(MOD_CLS_NAME);
bool utils_play_count(DSMSession* sc_sess, unsigned int cnt,
const string& basedir, const string& suffix, bool right) {
Modified: trunk/apps/dsm/mods/mod_utils/ModUtils.h
===================================================================
--- trunk/apps/dsm/mods/mod_utils/ModUtils.h 2009-10-14 12:00:58 UTC (rev
1541)
+++ trunk/apps/dsm/mods/mod_utils/ModUtils.h 2009-10-14 14:00:53 UTC (rev
1542)
@@ -28,16 +28,9 @@
#define _MOD_UTILS_H
#include "DSMModule.h"
-class SCUtilsModule
-: public DSMModule {
+#define MOD_CLS_NAME SCUtilsModule
- public:
- SCUtilsModule();
- ~SCUtilsModule();
-
- DSMAction* getAction(const string& from_str);
- DSMCondition* getCondition(const string& from_str);
-};
+DECLARE_MODULE(MOD_CLS_NAME);
DEF_ACTION_2P(SCUPlayCountRightAction);
DEF_ACTION_2P(SCUPlayCountLeftAction);
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev