diff options
author | Henri Herscher <henri@oreka.org> | 2006-06-30 19:39:27 +0000 |
---|---|---|
committer | Henri Herscher <henri@oreka.org> | 2006-06-30 19:39:27 +0000 |
commit | 868a99733ddb6a44f660f4aab9089fd619f38cfa (patch) | |
tree | 487309e2706b8389bc8985283c5d29334343bf7e /orkbasecxx/messages | |
parent | 3868172df25ae59bd0ecc524b782ac4734812891 (diff) |
Moved more stuff to orkbasecxx
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@287 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx/messages')
-rw-r--r-- | orkbasecxx/messages/CaptureMsg.cpp | 84 | ||||
-rw-r--r-- | orkbasecxx/messages/CaptureMsg.h | 51 | ||||
-rw-r--r-- | orkbasecxx/messages/DeleteTapeMsg.cpp | 60 | ||||
-rw-r--r-- | orkbasecxx/messages/DeleteTapeMsg.h | 33 | ||||
-rw-r--r-- | orkbasecxx/messages/PingMsg.cpp | 60 | ||||
-rw-r--r-- | orkbasecxx/messages/PingMsg.h | 46 | ||||
-rw-r--r-- | orkbasecxx/messages/TapeMsg.cpp | 88 | ||||
-rw-r--r-- | orkbasecxx/messages/TapeMsg.h | 85 | ||||
-rw-r--r-- | orkbasecxx/messages/TestMsg.cpp | 53 | ||||
-rw-r--r-- | orkbasecxx/messages/TestMsg.h | 55 |
10 files changed, 615 insertions, 0 deletions
diff --git a/orkbasecxx/messages/CaptureMsg.cpp b/orkbasecxx/messages/CaptureMsg.cpp new file mode 100644 index 0000000..f013e1f --- /dev/null +++ b/orkbasecxx/messages/CaptureMsg.cpp @@ -0,0 +1,84 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "Utils.h" +#include "CaptureMsg.h" +//#include "LogManager.h" +#include "CapturePluginProxy.h" + +#define CAPTURE_CLASS "capture" +#define CAPTURE_RESPONSE_CLASS "captureresponse" +#define CAPTURE_STATE_PARAM "state" +#define COMMENT_PARAM "comment" + +void CaptureResponseMsg::Define(Serializer* s) +{ + s->BoolValue(SUCCESS_PARAM, m_success); + s->StringValue(COMMENT_PARAM, m_comment); +} + +CStdString CaptureResponseMsg::GetClassName() +{ + return CStdString(CAPTURE_RESPONSE_CLASS); +} + +ObjectRef CaptureResponseMsg::NewInstance() +{ + return ObjectRef(new CaptureResponseMsg); +} + +//=============================== + +void CaptureMsg::Define(Serializer* s) +{ + CStdString captureClass(CAPTURE_CLASS); + s->StringValue(OBJECT_TYPE_TAG, captureClass, true); + s->StringValue(CAPTURE_PORT_PARAM, m_capturePort, true); + s->EnumValue(CAPTURE_STATE_PARAM, (int&)m_eventType, CaptureEvent::EventTypeToEnum, CaptureEvent::EventTypeToString, true); +} + + +CStdString CaptureMsg::GetClassName() +{ + return CStdString(CAPTURE_CLASS); +} + +ObjectRef CaptureMsg::NewInstance() +{ + return ObjectRef(new CaptureMsg); +} + +ObjectRef CaptureMsg::Process() +{ + CaptureResponseMsg* msg = new CaptureResponseMsg; + ObjectRef ref(msg); + + if(m_eventType == CaptureEvent::EtStart) + { + CapturePluginProxySingleton::instance()->StartCapture(m_capturePort); + msg->m_success = true; + } + else if(m_eventType == CaptureEvent::EtStop) + { + CapturePluginProxySingleton::instance()->StopCapture(m_capturePort); + msg->m_success = true; + } + else + { + msg->m_success = false; + msg->m_comment = CAPTURE_STATE_PARAM; + msg->m_comment += " needs to be start or stop"; + } + return ref; +} + diff --git a/orkbasecxx/messages/CaptureMsg.h b/orkbasecxx/messages/CaptureMsg.h new file mode 100644 index 0000000..782f70f --- /dev/null +++ b/orkbasecxx/messages/CaptureMsg.h @@ -0,0 +1,51 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#ifndef __CAPTUREMSG_H__ +#define __CAPTUREMSG_H__ + +#include "messages/SyncMessage.h" +#include "messages/AsyncMessage.h" +#include "AudioCapture.h" + + +class CaptureResponseMsg : public AsyncMessage +{ +public: + void Define(Serializer* s); + inline void Validate() {}; + + CStdString GetClassName(); + ObjectRef NewInstance(); + inline ObjectRef Process() {return ObjectRef();}; + + bool m_success; + CStdString m_comment; +}; + +class CaptureMsg : public SyncMessage +{ +public: + void Define(Serializer* s); + inline void Validate() {}; + + CStdString GetClassName(); + ObjectRef NewInstance(); + ObjectRef Process(); + + CaptureEvent::EventTypeEnum m_eventType; + CStdString m_capturePort; +}; + +#endif + diff --git a/orkbasecxx/messages/DeleteTapeMsg.cpp b/orkbasecxx/messages/DeleteTapeMsg.cpp new file mode 100644 index 0000000..9dc8dae --- /dev/null +++ b/orkbasecxx/messages/DeleteTapeMsg.cpp @@ -0,0 +1,60 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "DeleteTapeMsg.h" +#include "messages/AsyncMessage.h" + +#define DELETE_TAPE_CLASS "deletetape" + +void DeleteTapeMsg::Define(Serializer* s) +{ + CStdString deleteTapeClass(DELETE_TAPE_CLASS); + s->StringValue(OBJECT_TYPE_TAG, deleteTapeClass, true); + s->StringValue(FILENAME_PARAM, m_filename, true); +} + + +CStdString DeleteTapeMsg::GetClassName() +{ + return CStdString(DELETE_TAPE_CLASS); +} + +ObjectRef DeleteTapeMsg::NewInstance() +{ + return ObjectRef(new DeleteTapeMsg); +} + +ObjectRef DeleteTapeMsg::Process() +{ + SimpleResponseMsg* msg = new SimpleResponseMsg; + ObjectRef ref(msg); + + // Check that the audio file to delete is actually an audio file + if(m_filename.Find('/') != -1 && (m_filename.Find(".pcm") != -1 || m_filename.Find(".wav") != -1 )) + { + if (ACE_OS::unlink((PCSTR)m_filename) == -1) + { + msg->m_success = false; + msg->m_comment = "could not delete file"; + } + + } + else + { + msg->m_success = false; + msg->m_comment = "filename not valid"; + } + + return ref; +} + diff --git a/orkbasecxx/messages/DeleteTapeMsg.h b/orkbasecxx/messages/DeleteTapeMsg.h new file mode 100644 index 0000000..33fb9ae --- /dev/null +++ b/orkbasecxx/messages/DeleteTapeMsg.h @@ -0,0 +1,33 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#ifndef __DELETETAPEMSG_H__ +#define __DELETETAPEMSG_H__ + +#include "messages/SyncMessage.h" + +class DeleteTapeMsg : public SyncMessage +{ +public: + void Define(Serializer* s); + inline void Validate() {}; + + CStdString GetClassName(); + ObjectRef NewInstance(); + ObjectRef Process(); + + CStdString m_filename; +}; + +#endif + diff --git a/orkbasecxx/messages/PingMsg.cpp b/orkbasecxx/messages/PingMsg.cpp new file mode 100644 index 0000000..1f90bbe --- /dev/null +++ b/orkbasecxx/messages/PingMsg.cpp @@ -0,0 +1,60 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "PingMsg.h" + +#define PING_CLASS "ping" +#define PING_RESPONSE_CLASS "pingresponse" + +void PingResponseMsg::Define(Serializer* s) +{ + s->BoolValue(SUCCESS_PARAM, m_success); +} + +CStdString PingResponseMsg::GetClassName() +{ + return CStdString(PING_RESPONSE_CLASS); +} + +ObjectRef PingResponseMsg::NewInstance() +{ + return ObjectRef(new PingResponseMsg); +} + +//=============================== + +void PingMsg::Define(Serializer* s) +{ + CStdString pingClass(PING_CLASS); + s->StringValue(OBJECT_TYPE_TAG, pingClass, true); +} + + +CStdString PingMsg::GetClassName() +{ + return CStdString(PING_CLASS); +} + +ObjectRef PingMsg::NewInstance() +{ + return ObjectRef(new PingMsg); +} + +ObjectRef PingMsg::Process() +{ + PingResponseMsg* msg = new PingResponseMsg; + ObjectRef ref(msg); + msg->m_success = true; + return ref; +} + diff --git a/orkbasecxx/messages/PingMsg.h b/orkbasecxx/messages/PingMsg.h new file mode 100644 index 0000000..21b659a --- /dev/null +++ b/orkbasecxx/messages/PingMsg.h @@ -0,0 +1,46 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#ifndef __PINGMSG_H__ +#define __PINGMSG_H__ + +#include "messages/SyncMessage.h" +#include "messages/AsyncMessage.h" + + +class PingResponseMsg : public AsyncMessage +{ +public: + void Define(Serializer* s); + inline void Validate() {}; + + CStdString GetClassName(); + ObjectRef NewInstance(); + inline ObjectRef Process() {return ObjectRef();}; + + bool m_success; +}; + +class PingMsg : public SyncMessage +{ +public: + void Define(Serializer* s); + inline void Validate() {}; + + CStdString GetClassName(); + ObjectRef NewInstance(); + ObjectRef Process(); +}; + +#endif + diff --git a/orkbasecxx/messages/TapeMsg.cpp b/orkbasecxx/messages/TapeMsg.cpp new file mode 100644 index 0000000..b624d08 --- /dev/null +++ b/orkbasecxx/messages/TapeMsg.cpp @@ -0,0 +1,88 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "Utils.h" +#include "TapeMsg.h" +#include "ConfigManager.h" + +TapeMsg::TapeMsg() +{ + // Here is where default values are set + m_timestamp = 0; + m_direction = CaptureEvent::DirectionToString(CaptureEvent::DirUnkn); + m_duration = 0; + m_serviceName = CONFIG.m_serviceName; +} + +void TapeMsg::Define(Serializer* s) +{ + DefineMessage(s); + + CStdString tapeMessageName(TAPE_MESSAGE_NAME); + s->StringValue(OBJECT_TYPE_TAG, tapeMessageName, true); + s->StringValue(REC_ID_PARAM, m_recId, true); + s->StringValue(STAGE_PARAM, m_stage, true); + s->StringValue(CAPTURE_PORT_PARAM, m_capturePort, true); + s->IntValue(TIMESTAMP_PARAM, (int&)m_timestamp, true); + s->StringValue(FILENAME_PARAM, m_fileName, true); + s->StringValue(LOCALPARTY_PARAM, m_localParty); + s->StringValue(LOCALENTRYPOINT_PARAM, m_localEntryPoint); + s->StringValue(REMOTEPARTY_PARAM, m_remoteParty); + s->StringValue(DIRECTION_PARAM, m_direction); + s->IntValue(DURATION_PARAM, m_duration); + s->StringValue(SERVICE_PARAM, m_serviceName); + + s->StringValue(LOCAL_IP_PARAM, m_localIp); + s->StringValue(REMOTE_IP_PARAM, m_remoteIp); + //s->StringValue(LOCAL_MAC_PARAM, m_localMac); + //s->StringValue(REMOTE_MAC_PARAM, m_remoteMac); +} + +void TapeMsg::Validate() +{ +} + +CStdString TapeMsg::GetClassName() +{ + return CStdString(TAPE_MESSAGE_NAME); +} + +ObjectRef TapeMsg::NewInstance() +{ + return ObjectRef(new TapeMsg); +} + + +//========================================================== +TapeResponse::TapeResponse() +{ + m_deleteTape = false; +} + + +void TapeResponse::Define(Serializer* s) +{ + SimpleResponseMsg::Define(s); + s->BoolValue("deletetape", m_deleteTape); +} + +CStdString TapeResponse::GetClassName() +{ + return CStdString("taperesponse"); +} + +ObjectRef TapeResponse::NewInstance() +{ + return ObjectRef(new TapeResponse); +} + diff --git a/orkbasecxx/messages/TapeMsg.h b/orkbasecxx/messages/TapeMsg.h new file mode 100644 index 0000000..3165bb4 --- /dev/null +++ b/orkbasecxx/messages/TapeMsg.h @@ -0,0 +1,85 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#ifndef __TAPEMSG_H__ +#define __TAPEMSG_H__ + +#include "messages/SyncMessage.h" +#include "messages/AsyncMessage.h" +#include "AudioTape.h" + +#define TAPE_MESSAGE_NAME "tape" +#define REC_ID_PARAM "recid" +#define FILENAME_PARAM "filename" +#define STAGE_PARAM "stage" +#define LOCALPARTY_PARAM "localparty" +#define REMOTEPARTY_PARAM "remoteparty" +#define DIRECTION_PARAM "direction" +#define LOCALENTRYPOINT_PARAM "localentrypoint" +#define DURATION_PARAM "duration" +#define SERVICE_PARAM "service" +#define LOCAL_IP_PARAM "localip" +#define REMOTE_IP_PARAM "remoteip" +#define LOCAL_MAC_PARAM "localmac" +#define REMOTE_MAC_PARAM "remotemac" + +class TapeMsg : public SyncMessage +{ +public: + TapeMsg(); + + void Define(Serializer* s); + void Validate(); + + CStdString GetClassName(); + ObjectRef NewInstance(); + inline ObjectRef Process() {return ObjectRef();}; + + CStdString m_recId; + CStdString m_stage; + time_t m_timestamp; + CStdString m_fileName; + CStdString m_capturePort; + CStdString m_localParty; + CStdString m_localEntryPoint; + CStdString m_remoteParty; + CStdString m_direction; + CStdString m_loginString; + int m_duration; + CStdString m_serviceName; + CStdString m_localIp; + CStdString m_remoteIp; + CStdString m_localMac; + CStdString m_remoteMac; +}; + +typedef boost::shared_ptr<TapeMsg> TapeMsgRef; + +/** A TapeResponse is a response to TapeMsg +*/ +class TapeResponse : public SimpleResponseMsg +{ +public: + TapeResponse(); + void Define(Serializer* s); + inline void Validate() {}; + + CStdString GetClassName(); + ObjectRef NewInstance(); + inline ObjectRef Process() {return ObjectRef();}; + + bool m_deleteTape; +}; + +#endif + diff --git a/orkbasecxx/messages/TestMsg.cpp b/orkbasecxx/messages/TestMsg.cpp new file mode 100644 index 0000000..68e2f3e --- /dev/null +++ b/orkbasecxx/messages/TestMsg.cpp @@ -0,0 +1,53 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "Utils.h" +#include "TestMsg.h" + +TestMsg::TestMsg() +{ + // Here is where default values are set + m_timestamp = 0; +} + +void TestMsg::Define(Serializer* s) +{ + CStdString testMessageName("test"); + s->StringValue("test", testMessageName, true); + s->StringValue(STAGE_PARAM, m_stage, true); + s->StringValue(CAPTURE_PORT_PARAM, m_capturePort, true); + s->IntValue(TIMESTAMP_PARAM, (int&)m_timestamp, true); + s->StringValue(FILENAME_PARAM, m_fileName, true); + + s->StringValue(LOCALPARTY_PARAM, m_localParty); + s->StringValue(LOCALENTRYPOINT_PARAM, m_localEntryPoint); + s->StringValue(REMOTEPARTY_PARAM, m_remoteParty); + s->StringValue(DIRECTION_PARAM, m_direction); + s->CsvValue("csv", m_csv); + s->DateValue("date", m_time); +} + +void TestMsg::Validate() +{ +} + +CStdString TestMsg::GetClassName() +{ + return CStdString("test"); +} + +ObjectRef TestMsg::NewInstance() +{ + return ObjectRef(new TestMsg); +} + diff --git a/orkbasecxx/messages/TestMsg.h b/orkbasecxx/messages/TestMsg.h new file mode 100644 index 0000000..13aed71 --- /dev/null +++ b/orkbasecxx/messages/TestMsg.h @@ -0,0 +1,55 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +#ifndef __TESTMSG_H__ +#define __TESTMSG_H__ + +#include <list> +#include "messages/SyncMessage.h" + +#define FILENAME_PARAM "filename" +#define STAGE_PARAM "stage" +#define LOCALPARTY_PARAM "localparty" +#define REMOTEPARTY_PARAM "remoteparty" +#define DIRECTION_PARAM "direction" +#define LOCALENTRYPOINT_PARAM "localentrypoint" + +class TestMsg : public SyncMessage +{ +public: + TestMsg(); + + void Define(Serializer* s); + void Validate(); + + CStdString GetClassName(); + ObjectRef NewInstance(); + inline ObjectRef Process() {return ObjectRef();}; + + CStdString m_stage; + time_t m_timestamp; + CStdString m_fileName; + CStdString m_capturePort; + CStdString m_localParty; + CStdString m_localEntryPoint; + CStdString m_remoteParty; + CStdString m_direction; + CStdString m_loginString; + std::list<CStdString> m_csv; + time_t m_time; +}; + +typedef boost::shared_ptr<TestMsg> TestMsgRef; + +#endif + |