Hi,
In 1.5.0, the pluginloading has changed a bit, nudging us toward the use
of dyninvoke-style calling of plugin functions. in UserTimer, setTimer
with timeval argument was not exposed in the dyninvoke interface, the
attached patch fixes it. It also changes the pointer inside the ArgBlob
from char* to void* to reflect the generic nature of the class.
br
Szo
diff --git a/core/AmArg.cpp b/core/AmArg.cpp
index de7213e..d7ad148 100644
--- a/core/AmArg.cpp
+++ b/core/AmArg.cpp
@@ -439,6 +439,8 @@ string AmArg::print(const AmArg &a) {
return "<Object>";
case ADynInv:
return "<DynInv>";
+ case Blob:
+ s = "<Blob of size:" + int2str(a.asBlob()->len) + ">";
case Array:
s = "[";
for (size_t i = 0; i < a.size(); i ++)
diff --git a/core/AmArg.h b/core/AmArg.h
index 07ac73f..10e516b 100644
--- a/core/AmArg.h
+++ b/core/AmArg.h
@@ -51,7 +51,7 @@ class AmObject {
struct ArgBlob {
- char* data;
+ void* data;
int len;
ArgBlob()
@@ -61,14 +61,14 @@ struct ArgBlob {
ArgBlob(const ArgBlob& a) {
len = a.len;
- data = (char*)malloc(len);
+ data = malloc(len);
if (data)
memcpy(data, a.data, len);
}
- ArgBlob(const char* _data, int _len) {
+ ArgBlob(const void* _data, int _len) {
len = _len;
- data = (char*)malloc(len);
+ data = malloc(len);
if (data)
memcpy(data, _data, len);
}
diff --git a/core/plug-in/session_timer/UserTimer.cpp b/core/plug-in/session_timer/UserTimer.cpp
index 46162d1..4479cf8 100644
--- a/core/plug-in/session_timer/UserTimer.cpp
+++ b/core/plug-in/session_timer/UserTimer.cpp
@@ -228,6 +228,16 @@ void UserTimer::invoke(const string& method, const AmArg& args, AmArg& ret)
setTimer(args.get(0).asInt(),
args.get(1).asDouble(),
args.get(2).asCStr());
+ } else if (isArgBlob(args.get(1))) {
+ ArgBlob* blob = args.get(1).asBlob();
+ if(blob->len != sizeof(struct timeval)) {
+ ERROR("unsupported data in blob in '%s'\n", AmArg::print(args).c_str());
+ }
+ else {
+ setTimer(args.get(0).asInt(),
+ (struct timeval*)blob->data,
+ args.get(2).asCStr());
+ }
} else {
ERROR("unsupported timeout type in '%s'\n", AmArg::print(args).c_str());
}
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev