diff --git a/modules/action/action.cpp b/modules/action/action.cpp new file mode 100644 index 0000000..28bb58a --- /dev/null +++ b/modules/action/action.cpp @@ -0,0 +1,36 @@ +/* + Action + + Copyright (C) 2019 AleaJactaEst + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#include "action.h" + +void Action::_bind_methods() +{ + BIND_ENUM_CONSTANT(ACTION_POSITION_CODE); + BIND_ENUM_CONSTANT(ACTION_GENERIC_CODE); + BIND_ENUM_CONSTANT(ACTION_GENERIC_MULTI_PART_CODE); + BIND_ENUM_CONSTANT(ACTION_SINT64); + BIND_ENUM_CONSTANT(ACTION_SYNC_CODE); + BIND_ENUM_CONSTANT(ACTION_DISCONNECTION_CODE); + BIND_ENUM_CONSTANT(ACTION_ASSOCIATION_CODE); + BIND_ENUM_CONSTANT(ACTION_LOGIN_CODE); + BIND_ENUM_CONSTANT(ACTION_TARGET_SLOT_CODE); + BIND_ENUM_CONSTANT(ACTION_DUMMY_CODE); + BIND_ENUM_CONSTANT(ACTION_NONE); +} diff --git a/modules/action/action.h b/modules/action/action.h new file mode 100644 index 0000000..6ce7870 --- /dev/null +++ b/modules/action/action.h @@ -0,0 +1,49 @@ +/* + Header Action + + Copyright (C) 2019 AleaJactaEst + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#include "core/object.h" + +#ifndef ACTION_H +#define ACTION_H + +class Action : public Object +{ + GDCLASS(Action, Object) +protected: + static void _bind_methods(); +public: + enum CODE { + ACTION_POSITION_CODE = 0, + ACTION_GENERIC_CODE = 1, + ACTION_GENERIC_MULTI_PART_CODE = 2, + ACTION_SINT64 = 3, + ACTION_SYNC_CODE = 10, + ACTION_DISCONNECTION_CODE = 11, + ACTION_ASSOCIATION_CODE = 12, + ACTION_LOGIN_CODE = 13, + ACTION_TARGET_SLOT_CODE = 40, + ACTION_DUMMY_CODE = 99, + ACTION_NONE = 999 + }; +}; + +VARIANT_ENUM_CAST(Action::CODE); + +#endif \ No newline at end of file diff --git a/modules/action/action_genericmultipart.cpp b/modules/action/action_genericmultipart.cpp new file mode 100644 index 0000000..8dfc90a --- /dev/null +++ b/modules/action/action_genericmultipart.cpp @@ -0,0 +1,55 @@ +/* + Action Generic Multi Part + + Copyright (C) 2019 AleaJactaEst + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#include "action_genericmultipart.h" +#include "modules/debug/debug.h" + +void GenericMultiPart::add(uint16_t Part, PoolByteArray PartCont) +{ + if (this->_block.has(Part)) + { + this->_block[Part] = PartCont; + return; + } + this->_block[Part] = PartCont; +} + +bool GenericMultiPart::is_complete() +{ + if ( this->_block.size() != this->_size ) + return false; + return true; +} + +PoolByteArray GenericMultiPart::get_message() +{ + DBG_PRINT("get message " + itos(this->_id)); +#ifdef DEBUG_ENABLED + if ( is_complete() == false ) + { + ERR_PRINT("Missing some block id:" + itos(this->_id) + " " + itos(this->_block.size()) + "/" + itos(this->_size)); + } +#endif + int i; + PoolByteArray out; + for(i = 0; i < this->_size ; ++i) + out.append(this->_block[i]); + return out; +} \ No newline at end of file diff --git a/modules/action/action_genericmultipart.h b/modules/action/action_genericmultipart.h new file mode 100644 index 0000000..4b8533c --- /dev/null +++ b/modules/action/action_genericmultipart.h @@ -0,0 +1,44 @@ +/* + Action Generic Multi Part + + Copyright (C) 2019 AleaJactaEst + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#ifndef ACTION_GENERIC_MULTI_PART_H +#define ACTION_GENERIC_MULTI_PART_H + +#include "core/object.h" +// #include "core/array.h" +#include "core/dictionary.h" +#include "modules/networkconnection/network_data.h" + +class GenericMultiPart +{ + uint8_t _id; + uint16_t _size; + Dictionary _block; +public: + GenericMultiPart(uint8_t Number, uint16_t NbBlock) {_id = Number; _size = NbBlock;} + ~GenericMultiPart() {} + + void add(uint16_t Part, PoolByteArray PartCont); + bool is_complete(); + + PoolByteArray get_message(); +}; + +#endif \ No newline at end of file diff --git a/modules/impulse/impulse_phrase_send.cpp b/modules/impulse/impulse_phrase_send.cpp new file mode 100644 index 0000000..e69de29