Added missing rpcprotoutils file.

Updated files RPC with TransferState



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-rpc-b1@6331 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2013-04-22 22:43:02 +00:00
parent 19ac059ad2
commit 1f01eda2e2
5 changed files with 295 additions and 35 deletions

View File

@ -44,6 +44,7 @@ const ::google::protobuf::EnumDescriptor* ResponseShareDirList_ListType_descript
const ::google::protobuf::EnumDescriptor* RequestMsgIds_descriptor_ = NULL; const ::google::protobuf::EnumDescriptor* RequestMsgIds_descriptor_ = NULL;
const ::google::protobuf::EnumDescriptor* ResponseMsgIds_descriptor_ = NULL; const ::google::protobuf::EnumDescriptor* ResponseMsgIds_descriptor_ = NULL;
const ::google::protobuf::EnumDescriptor* Direction_descriptor_ = NULL; const ::google::protobuf::EnumDescriptor* Direction_descriptor_ = NULL;
const ::google::protobuf::EnumDescriptor* TransferState_descriptor_ = NULL;
} // namespace } // namespace
@ -55,11 +56,12 @@ void protobuf_AssignDesc_files_2eproto() {
"files.proto"); "files.proto");
GOOGLE_CHECK(file != NULL); GOOGLE_CHECK(file != NULL);
FileTransfer_descriptor_ = file->message_type(0); FileTransfer_descriptor_ = file->message_type(0);
static const int FileTransfer_offsets_[4] = { static const int FileTransfer_offsets_[5] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, file_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, file_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, direction_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, direction_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, fraction_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, fraction_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, rate_kbs_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, rate_kbs_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileTransfer, state_),
}; };
FileTransfer_reflection_ = FileTransfer_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection( new ::google::protobuf::internal::GeneratedMessageReflection(
@ -174,6 +176,7 @@ void protobuf_AssignDesc_files_2eproto() {
RequestMsgIds_descriptor_ = file->enum_type(0); RequestMsgIds_descriptor_ = file->enum_type(0);
ResponseMsgIds_descriptor_ = file->enum_type(1); ResponseMsgIds_descriptor_ = file->enum_type(1);
Direction_descriptor_ = file->enum_type(2); Direction_descriptor_ = file->enum_type(2);
TransferState_descriptor_ = file->enum_type(3);
} }
namespace { namespace {
@ -230,38 +233,44 @@ void protobuf_AddDesc_files_2eproto() {
::rsctrl::core::protobuf_AddDesc_core_2eproto(); ::rsctrl::core::protobuf_AddDesc_core_2eproto();
::google::protobuf::DescriptorPool::InternalAddGeneratedFile( ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n\013files.proto\022\014rsctrl.files\032\ncore.proto\"" "\n\013files.proto\022\014rsctrl.files\032\ncore.proto\""
"\177\n\014FileTransfer\022\037\n\004file\030\001 \002(\0132\021.rsctrl.c" "\253\001\n\014FileTransfer\022\037\n\004file\030\001 \002(\0132\021.rsctrl."
"ore.File\022*\n\tdirection\030\002 \002(\0162\027.rsctrl.fil" "core.File\022*\n\tdirection\030\002 \002(\0162\027.rsctrl.fi"
"es.Direction\022\020\n\010fraction\030\003 \002(\002\022\020\n\010rate_k" "les.Direction\022\020\n\010fraction\030\003 \002(\002\022\020\n\010rate_"
"Bs\030\004 \002(\002\"A\n\023RequestTransferList\022*\n\tdirec" "kBs\030\004 \002(\002\022*\n\005state\030\005 \002(\0162\033.rsctrl.files."
"tion\030\001 \002(\0162\027.rsctrl.files.Direction\"j\n\024R" "TransferState\"A\n\023RequestTransferList\022*\n\t"
"esponseTransferList\022#\n\006status\030\001 \002(\0132\023.rs" "direction\030\001 \002(\0162\027.rsctrl.files.Direction"
"ctrl.core.Status\022-\n\ttransfers\030\002 \003(\0132\032.rs" "\"j\n\024ResponseTransferList\022#\n\006status\030\001 \002(\013"
"ctrl.files.FileTransfer\"\204\002\n\026RequestContr" "2\023.rsctrl.core.Status\022-\n\ttransfers\030\002 \003(\013"
"olDownload\022\037\n\004file\030\001 \002(\0132\021.rsctrl.core.F" "2\032.rsctrl.files.FileTransfer\"\204\002\n\026Request"
"ile\022;\n\006action\030\002 \002(\0162+.rsctrl.files.Reque" "ControlDownload\022\037\n\004file\030\001 \002(\0132\021.rsctrl.c"
"stControlDownload.Action\"\213\001\n\006Action\022\020\n\014A" "ore.File\022;\n\006action\030\002 \002(\0162+.rsctrl.files."
"CTION_START\020\001\022\023\n\017ACTION_CONTINUE\020\002\022\017\n\013AC" "RequestControlDownload.Action\"\213\001\n\006Action"
"TION_WAIT\020\003\022\020\n\014ACTION_PAUSE\020\004\022\022\n\016ACTION_" "\022\020\n\014ACTION_START\020\001\022\023\n\017ACTION_CONTINUE\020\002\022"
"RESTART\020\005\022\020\n\014ACTION_CHECK\020\006\022\021\n\rACTION_CA" "\017\n\013ACTION_WAIT\020\003\022\020\n\014ACTION_PAUSE\020\004\022\022\n\016AC"
"NCEL\020\007\">\n\027ResponseControlDownload\022#\n\006sta" "TION_RESTART\020\005\022\020\n\014ACTION_CHECK\020\006\022\021\n\rACTI"
"tus\030\001 \002(\0132\023.rsctrl.core.Status\"3\n\023Reques" "ON_CANCEL\020\007\">\n\027ResponseControlDownload\022#"
"tShareDirList\022\016\n\006ssl_id\030\001 \002(\t\022\014\n\004path\030\002 " "\n\006status\030\001 \002(\0132\023.rsctrl.core.Status\"3\n\023R"
"\002(\t\"\224\002\n\024ResponseShareDirList\022#\n\006status\030\001" "equestShareDirList\022\016\n\006ssl_id\030\001 \002(\t\022\014\n\004pa"
" \002(\0132\023.rsctrl.core.Status\022\016\n\006ssl_id\030\002 \002(" "th\030\002 \002(\t\"\224\002\n\024ResponseShareDirList\022#\n\006sta"
"\t\022\014\n\004path\030\003 \002(\t\022>\n\tlist_type\030\004 \002(\0162+.rsc" "tus\030\001 \002(\0132\023.rsctrl.core.Status\022\016\n\006ssl_id"
"trl.files.ResponseShareDirList.ListType\022" "\030\002 \002(\t\022\014\n\004path\030\003 \002(\t\022>\n\tlist_type\030\004 \002(\0162"
" \n\005files\030\005 \003(\0132\021.rsctrl.core.File\"W\n\010Lis" "+.rsctrl.files.ResponseShareDirList.List"
"tType\022\021\n\rDIRQUERY_ROOT\020\001\022\023\n\017DIRQUERY_PER" "Type\022 \n\005files\030\005 \003(\0132\021.rsctrl.core.File\"W"
"SON\020\002\022\021\n\rDIRQUERY_FILE\020\003\022\020\n\014DIRQUERY_DIR" "\n\010ListType\022\021\n\rDIRQUERY_ROOT\020\001\022\023\n\017DIRQUER"
"\020\004*o\n\rRequestMsgIds\022\035\n\031MsgId_RequestTran" "Y_PERSON\020\002\022\021\n\rDIRQUERY_FILE\020\003\022\020\n\014DIRQUER"
"sferList\020\001\022 \n\034MsgId_RequestControlDownlo" "Y_DIR\020\004*o\n\rRequestMsgIds\022\035\n\031MsgId_Reques"
"ad\020\002\022\035\n\031MsgId_RequestShareDirList\020\003*s\n\016R" "tTransferList\020\001\022 \n\034MsgId_RequestControlD"
"esponseMsgIds\022\036\n\032MsgId_ResponseTransferL" "ownload\020\002\022\035\n\031MsgId_RequestShareDirList\020\003"
"ist\020\001\022!\n\035MsgId_ResponseControlDownload\020\002" "*s\n\016ResponseMsgIds\022\036\n\032MsgId_ResponseTran"
"\022\036\n\032MsgId_ResponseShareDirList\020\003*9\n\tDire" "sferList\020\001\022!\n\035MsgId_ResponseControlDownl"
"ction\022\024\n\020DIRECTION_UPLOAD\020\001\022\026\n\022DIRECTION" "oad\020\002\022\036\n\032MsgId_ResponseShareDirList\020\003*9\n"
"_DOWNLOAD\020\002", 1291); "\tDirection\022\024\n\020DIRECTION_UPLOAD\020\001\022\026\n\022DIRE"
"CTION_DOWNLOAD\020\002*\304\001\n\rTransferState\022\023\n\017TR"
"ANSFER_FAILED\020\001\022\021\n\rTRANSFER_OKAY\020\002\022\023\n\017TR"
"ANSFER_PAUSED\020\003\022\023\n\017TRANSFER_QUEUED\020\004\022\024\n\020"
"TRANSFER_WAITING\020\005\022\030\n\024TRANSFER_DOWNLOADI"
"NG\020\006\022\032\n\026TRANSFER_CHECKING_HASH\020\007\022\025\n\021TRAN"
"SFER_COMPLETE\020\010", 1535);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"files.proto", &protobuf_RegisterTypes); "files.proto", &protobuf_RegisterTypes);
FileTransfer::default_instance_ = new FileTransfer(); FileTransfer::default_instance_ = new FileTransfer();
@ -332,6 +341,26 @@ bool Direction_IsValid(int value) {
} }
} }
const ::google::protobuf::EnumDescriptor* TransferState_descriptor() {
protobuf_AssignDescriptorsOnce();
return TransferState_descriptor_;
}
bool TransferState_IsValid(int value) {
switch(value) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
return true;
default:
return false;
}
}
// =================================================================== // ===================================================================
@ -340,6 +369,7 @@ const int FileTransfer::kFileFieldNumber;
const int FileTransfer::kDirectionFieldNumber; const int FileTransfer::kDirectionFieldNumber;
const int FileTransfer::kFractionFieldNumber; const int FileTransfer::kFractionFieldNumber;
const int FileTransfer::kRateKBsFieldNumber; const int FileTransfer::kRateKBsFieldNumber;
const int FileTransfer::kStateFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
FileTransfer::FileTransfer() FileTransfer::FileTransfer()
@ -363,6 +393,7 @@ void FileTransfer::SharedCtor() {
direction_ = 1; direction_ = 1;
fraction_ = 0; fraction_ = 0;
rate_kbs_ = 0; rate_kbs_ = 0;
state_ = 1;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -404,6 +435,7 @@ void FileTransfer::Clear() {
direction_ = 1; direction_ = 1;
fraction_ = 0; fraction_ = 0;
rate_kbs_ = 0; rate_kbs_ = 0;
state_ = 1;
} }
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear(); mutable_unknown_fields()->Clear();
@ -477,6 +509,27 @@ bool FileTransfer::MergePartialFromCodedStream(
} else { } else {
goto handle_uninterpreted; goto handle_uninterpreted;
} }
if (input->ExpectTag(40)) goto parse_state;
break;
}
// required .rsctrl.files.TransferState state = 5;
case 5: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
parse_state:
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (rsctrl::files::TransferState_IsValid(value)) {
set_state(static_cast< rsctrl::files::TransferState >(value));
} else {
mutable_unknown_fields()->AddVarint(5, value);
}
} else {
goto handle_uninterpreted;
}
if (input->ExpectAtEnd()) return true; if (input->ExpectAtEnd()) return true;
break; break;
} }
@ -521,6 +574,12 @@ void FileTransfer::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->rate_kbs(), output); ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->rate_kbs(), output);
} }
// required .rsctrl.files.TransferState state = 5;
if (has_state()) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
5, this->state(), output);
}
if (!unknown_fields().empty()) { if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields( ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output); unknown_fields(), output);
@ -552,6 +611,12 @@ void FileTransfer::SerializeWithCachedSizes(
target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->rate_kbs(), target); target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->rate_kbs(), target);
} }
// required .rsctrl.files.TransferState state = 5;
if (has_state()) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
5, this->state(), target);
}
if (!unknown_fields().empty()) { if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target); unknown_fields(), target);
@ -586,6 +651,12 @@ int FileTransfer::ByteSize() const {
total_size += 1 + 4; total_size += 1 + 4;
} }
// required .rsctrl.files.TransferState state = 5;
if (has_state()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->state());
}
} }
if (!unknown_fields().empty()) { if (!unknown_fields().empty()) {
total_size += total_size +=
@ -625,6 +696,9 @@ void FileTransfer::MergeFrom(const FileTransfer& from) {
if (from.has_rate_kbs()) { if (from.has_rate_kbs()) {
set_rate_kbs(from.rate_kbs()); set_rate_kbs(from.rate_kbs());
} }
if (from.has_state()) {
set_state(from.state());
}
} }
mutable_unknown_fields()->MergeFrom(from.unknown_fields()); mutable_unknown_fields()->MergeFrom(from.unknown_fields());
} }
@ -642,7 +716,7 @@ void FileTransfer::CopyFrom(const FileTransfer& from) {
} }
bool FileTransfer::IsInitialized() const { bool FileTransfer::IsInitialized() const {
if ((_has_bits_[0] & 0x0000000f) != 0x0000000f) return false; if ((_has_bits_[0] & 0x0000001f) != 0x0000001f) return false;
if (has_file()) { if (has_file()) {
if (!this->file().IsInitialized()) return false; if (!this->file().IsInitialized()) return false;
@ -656,6 +730,7 @@ void FileTransfer::Swap(FileTransfer* other) {
std::swap(direction_, other->direction_); std::swap(direction_, other->direction_);
std::swap(fraction_, other->fraction_); std::swap(fraction_, other->fraction_);
std::swap(rate_kbs_, other->rate_kbs_); std::swap(rate_kbs_, other->rate_kbs_);
std::swap(state_, other->state_);
std::swap(_has_bits_[0], other->_has_bits_[0]); std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_); _unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_); std::swap(_cached_size_, other->_cached_size_);

View File

@ -146,6 +146,31 @@ inline bool Direction_Parse(
return ::google::protobuf::internal::ParseNamedEnum<Direction>( return ::google::protobuf::internal::ParseNamedEnum<Direction>(
Direction_descriptor(), name, value); Direction_descriptor(), name, value);
} }
enum TransferState {
TRANSFER_FAILED = 1,
TRANSFER_OKAY = 2,
TRANSFER_PAUSED = 3,
TRANSFER_QUEUED = 4,
TRANSFER_WAITING = 5,
TRANSFER_DOWNLOADING = 6,
TRANSFER_CHECKING_HASH = 7,
TRANSFER_COMPLETE = 8
};
bool TransferState_IsValid(int value);
const TransferState TransferState_MIN = TRANSFER_FAILED;
const TransferState TransferState_MAX = TRANSFER_COMPLETE;
const int TransferState_ARRAYSIZE = TransferState_MAX + 1;
const ::google::protobuf::EnumDescriptor* TransferState_descriptor();
inline const ::std::string& TransferState_Name(TransferState value) {
return ::google::protobuf::internal::NameOfEnum(
TransferState_descriptor(), value);
}
inline bool TransferState_Parse(
const ::std::string& name, TransferState* value) {
return ::google::protobuf::internal::ParseNamedEnum<TransferState>(
TransferState_descriptor(), name, value);
}
// =================================================================== // ===================================================================
class FileTransfer : public ::google::protobuf::Message { class FileTransfer : public ::google::protobuf::Message {
@ -231,6 +256,13 @@ class FileTransfer : public ::google::protobuf::Message {
inline float rate_kbs() const; inline float rate_kbs() const;
inline void set_rate_kbs(float value); inline void set_rate_kbs(float value);
// required .rsctrl.files.TransferState state = 5;
inline bool has_state() const;
inline void clear_state();
static const int kStateFieldNumber = 5;
inline rsctrl::files::TransferState state() const;
inline void set_state(rsctrl::files::TransferState value);
// @@protoc_insertion_point(class_scope:rsctrl.files.FileTransfer) // @@protoc_insertion_point(class_scope:rsctrl.files.FileTransfer)
private: private:
inline void set_has_file(); inline void set_has_file();
@ -241,6 +273,8 @@ class FileTransfer : public ::google::protobuf::Message {
inline void clear_has_fraction(); inline void clear_has_fraction();
inline void set_has_rate_kbs(); inline void set_has_rate_kbs();
inline void clear_has_rate_kbs(); inline void clear_has_rate_kbs();
inline void set_has_state();
inline void clear_has_state();
::google::protobuf::UnknownFieldSet _unknown_fields_; ::google::protobuf::UnknownFieldSet _unknown_fields_;
@ -248,9 +282,10 @@ class FileTransfer : public ::google::protobuf::Message {
int direction_; int direction_;
float fraction_; float fraction_;
float rate_kbs_; float rate_kbs_;
int state_;
mutable int _cached_size_; mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
friend void protobuf_AddDesc_files_2eproto(); friend void protobuf_AddDesc_files_2eproto();
friend void protobuf_AssignDesc_files_2eproto(); friend void protobuf_AssignDesc_files_2eproto();
@ -1005,6 +1040,29 @@ inline void FileTransfer::set_rate_kbs(float value) {
rate_kbs_ = value; rate_kbs_ = value;
} }
// required .rsctrl.files.TransferState state = 5;
inline bool FileTransfer::has_state() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void FileTransfer::set_has_state() {
_has_bits_[0] |= 0x00000010u;
}
inline void FileTransfer::clear_has_state() {
_has_bits_[0] &= ~0x00000010u;
}
inline void FileTransfer::clear_state() {
state_ = 1;
clear_has_state();
}
inline rsctrl::files::TransferState FileTransfer::state() const {
return static_cast< rsctrl::files::TransferState >(state_);
}
inline void FileTransfer::set_state(rsctrl::files::TransferState value) {
GOOGLE_DCHECK(rsctrl::files::TransferState_IsValid(value));
set_has_state();
state_ = value;
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// RequestTransferList // RequestTransferList
@ -1526,6 +1584,10 @@ template <>
inline const EnumDescriptor* GetEnumDescriptor< rsctrl::files::Direction>() { inline const EnumDescriptor* GetEnumDescriptor< rsctrl::files::Direction>() {
return rsctrl::files::Direction_descriptor(); return rsctrl::files::Direction_descriptor();
} }
template <>
inline const EnumDescriptor* GetEnumDescriptor< rsctrl::files::TransferState>() {
return rsctrl::files::TransferState_descriptor();
}
} // namespace google } // namespace google
} // namespace protobuf } // namespace protobuf

View File

@ -180,6 +180,35 @@ int RpcProtoFiles::processReqTransferList(uint32_t chan_id, uint32_t /* msg_id *
transfer->set_fraction( (float) info.transfered / info.size ); transfer->set_fraction( (float) info.transfered / info.size );
transfer->set_rate_kbs( info.tfRate ); transfer->set_rate_kbs( info.tfRate );
switch(info.downloadStatus)
{
case FT_STATE_FAILED:
transfer->set_state(rsctrl::files::TRANSFER_FAILED);
break;
default:
case FT_STATE_OKAY:
transfer->set_state(rsctrl::files::TRANSFER_OKAY);
break;
case FT_STATE_PAUSED:
transfer->set_state(rsctrl::files::TRANSFER_PAUSED);
break;
case FT_STATE_QUEUED:
transfer->set_state(rsctrl::files::TRANSFER_QUEUED);
break;
case FT_STATE_WAITING:
transfer->set_state(rsctrl::files::TRANSFER_WAITING);
break;
case FT_STATE_DOWNLOADING:
transfer->set_state(rsctrl::files::TRANSFER_DOWNLOADING);
break;
case FT_STATE_CHECKING_HASH:
transfer->set_state(rsctrl::files::TRANSFER_CHECKING_HASH);
break;
case FT_STATE_COMPLETE:
transfer->set_state(rsctrl::files::TRANSFER_COMPLETE);
break;
}
} }
/* DONE - Generate Reply */ /* DONE - Generate Reply */

View File

@ -0,0 +1,59 @@
/*
* RetroShare External Interface.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rpc/proto/rpcprotoutils.h"
#include <sys/time.h>
double getTimeStamp()
{
struct timeval tv;
double ts = 0;
if (0 == gettimeofday(&tv, NULL))
{
ts = tv.tv_sec + (tv.tv_usec / 1000000.0);
}
return ts;
}
bool setTimeStamp(rsctrl::core::Timestamp *ts)
{
struct timeval tv;
if (0 != gettimeofday(&tv, NULL))
{
ts->set_secs(tv.tv_sec);
ts->set_microsecs(tv.tv_usec);
return true;
}
else
{
ts->set_secs(0);
ts->set_microsecs(0);
return false;
}
return false;
}

View File

@ -0,0 +1,35 @@
/*
* RetroShare External Interface.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef RS_RPC_PROTO_UTILS_H
#define RS_RPC_PROTO_UTILS_H
#include "rpc/proto/gencc/core.pb.h"
double getTimeStamp();
bool setTimeStamp(rsctrl::core::Timestamp *ts);
#endif /* RS_RPC_PROTO_UTILS_H */