[asterisk-scf-commits] team/kpfleming/fosdem2011.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Sun Feb 6 03:21:07 CST 2011
branch "master" has been updated
via ae33998f390fc8b1b3e1e42ce0a689d66edbdfa4 (commit)
from 57c0bbea56fae6585ecf13f0628f79e437ee9e74 (commit)
Summary of changes:
.gitignore | 1 +
Makefile | 5 +++-
fred.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fred.java | 4 +++
fred.py | 6 ++++-
fredHook.java | 1 -
6 files changed, 78 insertions(+), 3 deletions(-)
create mode 100644 fred.cpp
- Log -----------------------------------------------------------------
commit ae33998f390fc8b1b3e1e42ce0a689d66edbdfa4
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Sun Feb 6 10:20:52 2011 +0100
Clean up formatting a bit.
Add a C++ example.
diff --git a/.gitignore b/.gitignore
index d1c8995..fc11bf7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.class
*.pyc
+fred
diff --git a/Makefile b/Makefile
index 11864ed..4dd811e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,10 @@
export CLASSPATH=/home/kpfleming/git/asterisk-scf/fosdem:/home/kpfleming/git/asterisk-scf/gitall/slice/java/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
export PYTHONPATH=/opt/Ice-3.4/python:/home/kpfleming/git/asterisk-scf/gitall/slice/python
-all: fred.class fred.pyc
+all: fred.class fred.pyc fred
+
+fred: fred.cpp
+ g++ -o $@ -I/opt/Ice-3.4/include -I/usr/local/include -L/opt/Ice-3.4/lib64 -L/usr/local/lib -lIce -lIceUtil -lasterisk-scf-api $<
fredHook.class: fredHook.java
javac -Xlint:deprecation $<
diff --git a/fred.cpp b/fred.cpp
new file mode 100644
index 0000000..79ec162
--- /dev/null
+++ b/fred.cpp
@@ -0,0 +1,64 @@
+#include <Ice/Ice.h>
+
+#include <AsteriskSCF/System/Hook/HookIf.h>
+#include <AsteriskSCF/SIP/SIPExtensionPointIf.h>
+
+using namespace std;
+using namespace Ice;
+using namespace AsteriskSCF::System::Hook::V1;
+using namespace AsteriskSCF::SIP::ExtensionPoint::V1;
+
+struct fredHook : virtual public AuthHook
+{
+ ObjectAdapterPtr _adapter;
+ AuthHookPrx _proxy;
+
+ fredHook(ObjectAdapterPtr adapter) : _adapter(adapter)
+ {
+ _proxy = AuthHookPrx::uncheckedCast(_adapter->addWithUUID(this));
+ }
+
+ HookResult challengeRequest(const RequestInfoPtr& info, DigestChallengeSeq& challenges, const Ice::Current&)
+ {
+ HookResult result;
+ DigestChallengePtr challenge = new DigestChallenge();
+
+ challenge->username = "bob";
+ challenge->password = "alice";
+ challenge->domain.push_back("example.com");
+ challenge->algorithm = AKAv1MD5;
+
+ challenges.push_back(challenge);
+
+ result.status = Succeeded;
+ return result;
+ }
+};
+
+struct fred : virtual public Ice::Application
+{
+ virtual int run(int, char*[])
+ {
+ ObjectAdapterPtr adapter = communicator()->createObjectAdapter("fred");
+ adapter->activate();
+
+ IceUtil::Handle<fredHook> hook(new fredHook(adapter));
+
+ // this sample code does not actually locate the target SIP component
+ AuthExtensionPointPrx epPrx = AuthExtensionPointPrx::uncheckedCast(communicator()->stringToProxy("sip_component"));
+ RequestTypeSeq requestTypes;
+ requestTypes.push_back(DialogEstablishing);
+ HookId _hookId = epPrx->addAuthHook(hook->_proxy, requestTypes);
+
+ communicator()->waitForShutdown();
+ epPrx->removeAuthHook(_hookId);
+
+ return 0;
+ }
+};
+
+int main(int argc, char *argv[])
+{
+ fred app;
+ return app.main(argc, argv);
+}
diff --git a/fred.java b/fred.java
index 91e8137..563f2f7 100644
--- a/fred.java
+++ b/fred.java
@@ -10,12 +10,16 @@ public class fred extends Ice.Application
Ice.ObjectAdapter adapter = communicator().createObjectAdapter("fred");
adapter.activate();
fredHook._adapter = adapter;
+
fredHook hook = new fredHook();
+
// this sample code does not actually locate the target SIP component
AuthExtensionPointPrx epPrx = AuthExtensionPointPrxHelper.uncheckedCast(communicator().stringToProxy("sip_component"));
_hookId = epPrx.addAuthHook(hook._proxy, new RequestType[]{ RequestType.DialogEstablishing });
+
communicator().waitForShutdown();
epPrx.removeAuthHook(_hookId);
+
return 0;
}
diff --git a/fred.py b/fred.py
index 044c8d4..b548d05 100644
--- a/fred.py
+++ b/fred.py
@@ -31,12 +31,16 @@ class fred(Ice.Application):
adapter = self.communicator().createObjectAdapter("fred")
adapter.activate()
fredHook._adapter = adapter
+
hook = fredHook()
- # this sample code does not actually locate the target SIP component
+
+ # this sample code does not actually locate the target SIP component
epPrx = AuthExtensionPointPrx.uncheckedCast(communicator().stringToProxy("sip_component"))
_hookId = epPrx.addAuthHook(hook._proxy, [ RequestType.DialogEstablishing ])
+
self.communicator().waitForShutdown()
epPrx.removeAuthHook(_hookId)
+
return 0
app = fred()
diff --git a/fredHook.java b/fredHook.java
index 22b4c65..f0800c5 100644
--- a/fredHook.java
+++ b/fredHook.java
@@ -27,5 +27,4 @@ public class fredHook extends _AuthHookDisp
return result;
}
-
}
-----------------------------------------------------------------------
--
team/kpfleming/fosdem2011.git
More information about the asterisk-scf-commits
mailing list