a_alxparser.h | a_alxparser.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file a_alxparser.h | /// \file a_alxparser.h | |||
/// ALX file parser (for one file) | /// ALX file parser (for one file) | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010, Nicolas VIVIEN | Copyright (C) 2010, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
a_application.h | a_application.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file a_application.h | /// \file a_application.h | |||
/// ALX Application class based on CODSection class | /// ALX Application class based on CODSection class | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010, Nicolas VIVIEN | Copyright (C) 2010, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
a_codsection.h | a_codsection.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file a_codsection.h | /// \file a_codsection.h | |||
/// COD structure for the ALX file parser | /// COD structure for the ALX file parser | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010, Nicolas VIVIEN | Copyright (C) 2010, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
a_common.h | a_common.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file a_common.h | /// \file a_common.h | |||
/// ALX file parser common header | /// ALX file parser common header | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010, Nicolas VIVIEN | Copyright (C) 2010, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
a_library.h | a_library.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file a_library.h | /// \file a_library.h | |||
/// ALX Library class based on CODSection class | /// ALX Library class based on CODSection class | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010, Nicolas VIVIEN | Copyright (C) 2010, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
a_osloader.h | a_osloader.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file a_osloader.h | /// \file a_osloader.h | |||
/// OS files parser (multi ALX files parser) | /// OS files parser (multi ALX files parser) | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010, Nicolas VIVIEN | Copyright (C) 2010, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
backup.h | backup.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file backup.h | /// \file backup.h | |||
/// Special parser class to support creation of Barry Backup fil es | /// Special parser class to support creation of Barry Backup fil es | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 39 | skipping to change at line 39 | |||
// forward declarations | // forward declarations | |||
namespace reuse { | namespace reuse { | |||
class TarFile; | class TarFile; | |||
} | } | |||
namespace Barry { | namespace Barry { | |||
class BXEXPORT Backup : public Barry::Parser | class BXEXPORT Backup : public Barry::Parser | |||
{ | { | |||
public: | ||||
typedef std::map<std::string, int> StatsType; | ||||
private: | private: | |||
std::auto_ptr<reuse::TarFile> m_tar; | std::auto_ptr<reuse::TarFile> m_tar; | |||
std::string m_current_dbname; | std::string m_current_dbname; | |||
std::string m_tar_id_text; | std::string m_tar_id_text; | |||
std::string m_record_data; | std::string m_record_data; | |||
StatsType m_stats; | ||||
public: | public: | |||
explicit Backup(const std::string &tarpath); | explicit Backup(const std::string &tarpath); | |||
~Backup(); | ~Backup(); | |||
void Close(); | void Close(); | |||
void ClearStats(); | ||||
const StatsType& GetStats() const { return m_stats; } | ||||
// Barry::Parser overrides | // Barry::Parser overrides | |||
virtual void ParseRecord(const Barry::DBData &data, | virtual void ParseRecord(const Barry::DBData &data, | |||
const Barry::IConverter *ic); | const Barry::IConverter *ic); | |||
}; | }; | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 4 change blocks. | ||||
1 lines changed or deleted | 8 lines changed or added | |||
barry.h | barry.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file barry.h | /// \file barry.h | |||
/// Main header file for applications | /// Main header file for applications | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 79 | skipping to change at line 79 | |||
#include "log.h" | #include "log.h" | |||
#include "sha1.h" | #include "sha1.h" | |||
#include "iconv.h" | #include "iconv.h" | |||
#include "bmp.h" | #include "bmp.h" | |||
#include "cod.h" | #include "cod.h" | |||
#include "record.h" | #include "record.h" | |||
#include "threadwrap.h" | #include "threadwrap.h" | |||
#include "vsmartptr.h" | #include "vsmartptr.h" | |||
#include "pipe.h" | #include "pipe.h" | |||
#include "connector.h" | #include "connector.h" | |||
#include "fifoargs.h" | ||||
// Include the JDW Debug Parser classes | // Include the JDW Debug Parser classes | |||
#include "dp_codinfo.h" | #include "dp_codinfo.h" | |||
// Include the JDWP Server classes | // Include the JDWP Server classes | |||
#include "j_manager.h" | #include "j_manager.h" | |||
#include "j_server.h" | #include "j_server.h" | |||
// Include the template helpers after the record classes | // Include the template helpers after the record classes | |||
#include "m_desktoptmpl.h" | #include "m_desktoptmpl.h" | |||
#include "recordtmpl.h" | ||||
#ifdef __BARRY_BOOST_MODE__ | #ifdef __BARRY_BOOST_MODE__ | |||
// Boost serialization seems to be picky about header order, do them all he re | // Boost serialization seems to be picky about header order, do them all he re | |||
#include <iomanip> | #include <iomanip> | |||
#include <iostream> | #include <iostream> | |||
#include <fstream> | #include <fstream> | |||
#include <vector> | #include <vector> | |||
#include <string> | #include <string> | |||
#include <boost/archive/text_iarchive.hpp> | #include <boost/archive/text_iarchive.hpp> | |||
#include <boost/archive/text_oarchive.hpp> | #include <boost/archive/text_oarchive.hpp> | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 3 lines changed or added | |||
barryalx.h | barryalx.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file barryalx.h | /// \file barryalx.h | |||
/// Main header file for libbarryalx | /// Main header file for libbarryalx | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
barrybackup.h | barrybackup.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file barrybackup.h | /// \file barrybackup.h | |||
/// Main header file for libbarrybackup | /// Main header file for libbarrybackup | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
barrysync.h | barrysync.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file barrysync.h | /// \file barrysync.h | |||
/// Main header file for libbarrysync | /// Main header file for libbarrysync | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
bmp.h | bmp.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file bmp.h | /// \file bmp.h | |||
/// BMP conversion routines | /// BMP conversion routines | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2009-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2009-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
See the GNU General Public License in the COPYING file at the | See the GNU General Public License in the COPYING file at the | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __BARRY_BMP_H__ | #ifndef __BARRY_BMP_H__ | |||
#define __BARRY_BMP_H__ | #define __BARRY_BMP_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include "data.h" | #include <sys/types.h> | |||
#include "m_javaloader.h" | #include <stdint.h> | |||
namespace Barry { | namespace Barry { | |||
class Data; | ||||
class JLScreenInfo; | ||||
BXEXPORT size_t GetBitmapHeadersSize(); | ||||
BXEXPORT size_t GetTotalBitmapSize(const JLScreenInfo &info); | BXEXPORT size_t GetTotalBitmapSize(const JLScreenInfo &info); | |||
BXEXPORT void ScreenshotToRGB(const JLScreenInfo &info, | ||||
const Data &screenshot, Data &buffer, size_t offset, | ||||
int depth, bool invert, | ||||
bool overwrite_alpha = false, uint8_t alpha = 0xFF); | ||||
BXEXPORT void ScreenshotToBitmap(const JLScreenInfo &info, | BXEXPORT void ScreenshotToBitmap(const JLScreenInfo &info, | |||
const Data &screenshot, Data &bitmap); | const Data &screenshot, Data &bitmap); | |||
} | } | |||
#endif | #endif | |||
End of changes. 4 change blocks. | ||||
3 lines changed or deleted | 11 lines changed or added | |||
builder.h | builder.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file builder.h | /// \file builder.h | |||
/// Virtual protocol packet builder wrapper | /// Virtual protocol packet builder wrapper | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 137 | skipping to change at line 137 | |||
// | // | |||
// SetDBData | // SetDBData | |||
// | // | |||
/// Contains the proper way to convert a record object into a DBData object . | /// Contains the proper way to convert a record object into a DBData object . | |||
/// | /// | |||
template <class RecordT> | template <class RecordT> | |||
void SetDBData(const RecordT &rec, DBData &data, size_t &offset, | void SetDBData(const RecordT &rec, DBData &data, size_t &offset, | |||
const IConverter *ic) | const IConverter *ic) | |||
{ | { | |||
// Make sure record is valid before building it. | ||||
// This can throw Barry::ValidationError | ||||
rec.Validate(); | ||||
// Build the DBData object | ||||
data.SetVersion(DBData::REC_VERSION_1); | data.SetVersion(DBData::REC_VERSION_1); | |||
data.SetOffset(offset); | data.SetOffset(offset); | |||
data.SetDBName(RecordT::GetDBName()); | data.SetDBName(RecordT::GetDBName()); | |||
data.SetIds(rec.GetRecType(), rec.GetUniqueId()); | data.SetIds(rec.GetRecType(), rec.GetUniqueId()); | |||
rec.BuildHeader(data.UseData(), offset); | rec.BuildHeader(data.UseData(), offset); | |||
rec.BuildFields(data.UseData(), offset, ic); | rec.BuildFields(data.UseData(), offset, ic); | |||
} | } | |||
// | // | |||
// RecordBuilder template class | // RecordBuilder template class | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 6 lines changed or added | |||
cod.h | cod.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file cod.h | /// \file cod.h | |||
/// COD file API | /// COD file API | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2009-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2009-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
common.h | common.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file common.h | /// \file common.h | |||
/// General header for the Barry library | /// General header for the Barry library | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
See the GNU General Public License in the COPYING file at the | See the GNU General Public License in the COPYING file at the | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __BARRY_COMMON_H__ | #ifndef __BARRY_COMMON_H__ | |||
#define __BARRY_COMMON_H__ | #define __BARRY_COMMON_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include <iostream> | #include <iostream> | |||
#define VENDOR_RIM 0x0fca | #define VENDOR_RIM 0x0fca | |||
#define PRODUCT_RIM_BLACKBERRY 0x0001 | #define PRODUCT_RIM_BLACKBERRY 0x0001 | |||
#define PRODUCT_RIM_PEARL_DUAL 0x0004 | #define PRODUCT_RIM_PEARL_DUAL 0x0004 | |||
#define PRODUCT_RIM_PEARL_FLIP 0x8001 // 8200 series | #define PRODUCT_RIM_PEARL_FLIP 0x8001 // 8200 series | |||
#define PRODUCT_RIM_PEARL_8120 0x8004 | #define PRODUCT_RIM_PEARL_8120 0x8004 | |||
#define PRODUCT_RIM_PEARL 0x0006 | #define PRODUCT_RIM_PEARL 0x0006 | |||
#define PRODUCT_RIM_STORM 0x8007 | #define PRODUCT_RIM_STORM 0x8007 | |||
#define PRODUCT_RIM_PLAYBOOK_NETWORK 0x8011 | ||||
#define PRODUCT_RIM_PLAYBOOK_STORAGE 0x8020 | ||||
#define BLACKBERRY_INTERFACE 0 | #define BLACKBERRY_INTERFACE 0 | |||
#define BLACKBERRY_CONFIGURATION 1 | #define BLACKBERRY_CONFIGURATION 1 | |||
#define BLACKBERRY_MASS_STORAGE_CLASS 8 | ||||
#define BLACKBERRY_DB_CLASS 0xff | #define BLACKBERRY_DB_CLASS 0xff | |||
#define IPRODUCT_RIM_HANDHELD 2 | #define IPRODUCT_RIM_HANDHELD 2 | |||
#define IPRODUCT_RIM_MASS_STORAGE 4 | #define IPRODUCT_RIM_MASS_STORAGE 4 | |||
#define IPRODUCT_RIM_COMPOSITE 5 | #define IPRODUCT_RIM_COMPOSITE 5 | |||
// minimum number of password tries remaining at which Barry gives up | // minimum number of password tries remaining at which Barry gives up | |||
// for safety | // for safety | |||
#define BARRY_MIN_PASSWORD_TRIES 3 | #define BARRY_MIN_PASSWORD_TRIES 3 | |||
#define BARRY_MIN_PASSWORD_TRIES_ASC "3" | #define BARRY_MIN_PASSWORD_TRIES_ASC "3" | |||
#define BLACKBERRY_CHARSET "WINDOWS-1252" | #define BLACKBERRY_CHARSET "WINDOWS-1252" | |||
#define BARRY_FIFO_NAME "/tmp/barry_fifo_args" | ||||
namespace Barry { | namespace Barry { | |||
/// See also the LogLock class. | /// See also the LogLock class. | |||
BXEXPORT void Init(bool data_dump_mode = false, std::ostream *logStream = & std::cout); | BXEXPORT void Init(bool data_dump_mode = false, std::ostream *logStream = & std::cout); | |||
BXEXPORT void Verbose(bool data_dump_mode = true); | BXEXPORT void Verbose(bool data_dump_mode = true); | |||
BXEXPORT bool IsVerbose(); | BXEXPORT bool IsVerbose(); | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 4 change blocks. | ||||
8 lines changed or deleted | 13 lines changed or added | |||
configfile.h | configfile.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file configfile.h | /// \file configfile.h | |||
/// Barry configuraion class, for one device PIN | /// Barry configuraion class, for one device PIN | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2007-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2007-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 29 | skipping to change at line 29 | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __BARRY_CONFIGFILE_H__ | #ifndef __BARRY_CONFIGFILE_H__ | |||
#define __BARRY_CONFIGFILE_H__ | #define __BARRY_CONFIGFILE_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include "record.h" | #include "record.h" | |||
#include "pin.h" | #include "pin.h" | |||
#include <string> | #include <string> | |||
#include <iosfwd> | ||||
namespace Barry { | namespace Barry { | |||
/// Creates a tar.gz filename using PIN + date + time + label. | ||||
/// Does not include any path, just returns a new filename. | ||||
BXEXPORT std::string MakeBackupFilename(const Barry::Pin &pin, | ||||
const std::string &label); | ||||
class BXEXPORT ConfigFile | class BXEXPORT ConfigFile | |||
{ | { | |||
public: | public: | |||
class BXEXPORT DBListType : public std::vector<std::string> | class BXEXPORT DBListType : public std::vector<std::string> | |||
{ | { | |||
public: | public: | |||
bool IsSelected(const std::string &dbname) const; | bool IsSelected(const std::string &dbname) const; | |||
DBListType& operator=(const DatabaseDatabase &dbdb); | ||||
DBListType() {} | ||||
DBListType(const DatabaseDatabase &dbdb) | ||||
{ | ||||
operator=(dbdb); | ||||
} | ||||
}; | }; | |||
private: | private: | |||
// meta data | // meta data | |||
Barry::Pin m_pin; | Barry::Pin m_pin; | |||
std::string m_path; // /path/to/config/dir without trai ling slash | std::string m_path; // /path/to/config/dir without trai ling slash | |||
std::string m_filename; // /path/to/config/dir/filename | std::string m_filename; // /path/to/config/dir/filename | |||
bool m_loaded; | bool m_loaded; | |||
std::string m_last_error; | std::string m_last_error; | |||
// configuration data | // configuration data | |||
DBListType m_backupList; | DBListType m_backupList; | |||
DBListType m_restoreList; | DBListType m_restoreList; | |||
std::string m_deviceName; | std::string m_deviceName; | |||
bool m_promptBackupLabel; // if true, prompt the user on every | bool m_promptBackupLabel; // if true, prompt the user on every | |||
// backup for a string to label the | // backup for a string to label the | |||
// backup file with | // backup file with | |||
bool m_autoSelectAll; // if true, automatically select all | ||||
// databases on every backup | ||||
protected: | protected: | |||
void BuildFilename(); | void BuildFilename(); | |||
void BuildDefaultPath(); | void BuildDefaultPath(); | |||
void Clear(); | void Clear(); | |||
void Load(); | void Load(); | |||
public: | public: | |||
/// Loads config file for the given pin, and ends up in an | /// Loads config file for the given pin, and ends up in an | |||
/// unenlightened state. Throws ConfigFileError on error, | /// unenlightened state. Throws ConfigFileError on error, | |||
skipping to change at line 96 | skipping to change at line 112 | |||
// const std::string& GetDeviceConfigFilename() const { return m_device _filename; } | // const std::string& GetDeviceConfigFilename() const { return m_device _filename; } | |||
// | // | |||
// per-Device Configuration | // per-Device Configuration | |||
// | // | |||
const DBListType& GetBackupList() const { return m_backupList; } | const DBListType& GetBackupList() const { return m_backupList; } | |||
const DBListType& GetRestoreList() const { return m_restoreList; } | const DBListType& GetRestoreList() const { return m_restoreList; } | |||
const std::string& GetDeviceName() const { return m_deviceName; } | const std::string& GetDeviceName() const { return m_deviceName; } | |||
bool HasDeviceName() const { return m_deviceName.size(); } | bool HasDeviceName() const { return m_deviceName.size(); } | |||
bool PromptBackupLabel() const { return m_promptBackupLabel; } | bool PromptBackupLabel() const { return m_promptBackupLabel; } | |||
bool AutoSelectAll() const { return m_autoSelectAll; } | ||||
// | // | |||
// operations | // operations | |||
// | // | |||
/// Saves current device's config, overwriting or creating a | /// Saves current device's config, overwriting or creating a | |||
/// config file | /// config file | |||
bool Save(); | bool Save(); | |||
/// Compares a given databasedatabase from a real device with the | /// Compares a given databasedatabase from a real device with the | |||
skipping to change at line 121 | skipping to change at line 138 | |||
// per-Device Configuration setting | // per-Device Configuration setting | |||
// | // | |||
/// Sets list with new config | /// Sets list with new config | |||
void SetBackupList(const DBListType &list); | void SetBackupList(const DBListType &list); | |||
void SetRestoreList(const DBListType &list); | void SetRestoreList(const DBListType &list); | |||
void SetDeviceName(const std::string &name); | void SetDeviceName(const std::string &name); | |||
void SetBackupPath(const std::string &path); | void SetBackupPath(const std::string &path); | |||
void SetPromptBackupLabel(bool prompt = true); | void SetPromptBackupLabel(bool prompt = true); | |||
void SetAutoSelectAll(bool asa = true); | ||||
// | // | |||
// Utility functions | // Utility functions | |||
// | // | |||
/// Checks that the path in path exists, and if not, creates it. | /// Checks that the path in path exists, and if not, creates it. | |||
/// Returns false if unable to create path, true if ok. | /// Returns false if unable to create path, true if ok. | |||
static bool CheckPath(const std::string &path, std::string *perr = 0 ); | static bool CheckPath(const std::string &path, std::string *perr = 0 ); | |||
}; | }; | |||
skipping to change at line 175 | skipping to change at line 193 | |||
GlobalConfigFile(const std::string &appname); | GlobalConfigFile(const std::string &appname); | |||
~GlobalConfigFile(); | ~GlobalConfigFile(); | |||
// | // | |||
// data access | // data access | |||
// | // | |||
const std::string& get_last_error() const { return m_last_error; } | const std::string& get_last_error() const { return m_last_error; } | |||
bool IsConfigLoaded() const { return m_loaded; } | bool IsConfigLoaded() const { return m_loaded; } | |||
const std::string& GetPath() const { return m_path; } | ||||
// | // | |||
// Global Configuration data access | // Global Configuration data access | |||
// | // | |||
Barry::Pin GetLastDevice() const { return m_lastDevice; } | Barry::Pin GetLastDevice() const { return m_lastDevice; } | |||
bool VerboseLogging() const { return m_verboseLogging; } | bool VerboseLogging() const { return m_verboseLogging; } | |||
// | // | |||
// operations | // operations | |||
// | // | |||
/// Save the current global config, overwriting or creating as neede d | /// Save the current global config, overwriting or creating as neede d | |||
bool Save(); | bool Save(); | |||
/// Throws std::logic_error if not constructed with an appname | /// Throws std::logic_error if not constructed with an appname | |||
void SetKey(const std::string &key, const std::string &value); | void SetKey(const std::string &key, const std::string &value); | |||
std::string GetKey(const std::string &key) const; | ||||
/// Returns value for key, and returns default_value if key does not | ||||
/// exist in the config file. | ||||
/// Throws std::logic_error if not constructed with an appname | ||||
std::string GetKey(const std::string &key, | ||||
const std::string &default_value = "") const; | ||||
// | // | |||
// Global Configuration setting | // Global Configuration setting | |||
// | // | |||
void SetLastDevice(const Barry::Pin &pin); | void SetLastDevice(const Barry::Pin &pin); | |||
void SetVerboseLogging(bool verbose = true); | void SetVerboseLogging(bool verbose = true); | |||
}; | }; | |||
BXEXPORT std::ostream& operator<< (std::ostream &os, const ConfigFile::DBLi | ||||
stType &list); | ||||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 10 change blocks. | ||||
2 lines changed or deleted | 29 lines changed or added | |||
connector.h | connector.h | |||
---|---|---|---|---|
// | /// | |||
// \file connector.h | /// \file connector.h | |||
// Base class interface for handling Mode connections to device | /// Base class interface for handling Mode connections to device | |||
// | /// | |||
/* | /* | |||
Copyright (C) 2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2011-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 51 | skipping to change at line 51 | |||
class BXEXPORT Connector | class BXEXPORT Connector | |||
{ | { | |||
protected: | protected: | |||
std::string m_password; | std::string m_password; | |||
bool m_needs_reconnect; | bool m_needs_reconnect; | |||
Barry::IConverter m_ic; | Barry::IConverter m_ic; | |||
Barry::ProbeResult m_probe_result; | Barry::ProbeResult m_probe_result; | |||
int m_connect_count; | int m_connect_count; | |||
time_t m_last_disconnect; | time_t m_last_disconnect; | |||
// bad password status | ||||
BadPassword m_bpcopy; | ||||
protected: | protected: | |||
// helper functions | // helper functions | |||
static Barry::ProbeResult FindDevice(Barry::Pin pin); | static Barry::ProbeResult FindDevice(Barry::Pin pin); | |||
// required overrides by derived classes | // required overrides by derived classes | |||
virtual void StartConnect(const char *password) = 0; | virtual void StartConnect(const char *password) = 0; | |||
virtual void RetryPassword(const char *password) = 0; | virtual void RetryPassword(const char *password) = 0; | |||
virtual void FinishConnect() = 0; | virtual void FinishConnect() = 0; | |||
virtual void DoDisconnect() = 0; | virtual void DoDisconnect() = 0; | |||
/// slightly different than IsConnected()... this returns true | /// slightly different than IsConnected()... this returns true | |||
skipping to change at line 76 | skipping to change at line 79 | |||
Connector(const char *password, const std::string &locale, | Connector(const char *password, const std::string &locale, | |||
Barry::Pin pin = 0); | Barry::Pin pin = 0); | |||
Connector(const char *password, const std::string &locale, | Connector(const char *password, const std::string &locale, | |||
const Barry::ProbeResult &result); | const Barry::ProbeResult &result); | |||
virtual ~Connector(); | virtual ~Connector(); | |||
IConverter& GetIConverter() { return m_ic; } | IConverter& GetIConverter() { return m_ic; } | |||
const IConverter& GetIConverter() const { return m_ic; } | const IConverter& GetIConverter() const { return m_ic; } | |||
Barry::ProbeResult& GetProbeResult() { return m_probe_result; } | Barry::ProbeResult& GetProbeResult() { return m_probe_result; } | |||
const Barry::ProbeResult& GetProbeResult() const { return m_probe_re sult; } | const Barry::ProbeResult& GetProbeResult() const { return m_probe_re sult; } | |||
const Barry::BadPassword& GetBadPassword() const { return m_bpcopy; } | ||||
virtual void ClearPassword(); | virtual void ClearPassword(); | |||
virtual void SetPassword(const char *password); | virtual void SetPassword(const char *password); | |||
/// Returns true if connected, false if user cancelled, throws | /// Returns true if connected, false if user cancelled, throws | |||
/// Barry exception on error. | /// Barry exception on error. Note that in the case of a bad | |||
/// password, this will return false on the first password try, | ||||
/// unless you override PasswordPrompt() below. In the default | ||||
/// case, a false here means the password was invalid, and you | ||||
/// should use GetBadPassword() to report the error. | ||||
virtual bool Connect(); | virtual bool Connect(); | |||
/// Disconnects from the device | /// Disconnects from the device | |||
virtual void Disconnect(); | virtual void Disconnect(); | |||
/// Returns same as Connect(), but normally remembers the password | /// Returns same as Connect(), but normally remembers the password | |||
/// and so avoids prompting the user if possible. Password prompts | /// and so avoids prompting the user if possible. Password prompts | |||
/// are still possible though, if you have called ClearPassword(). | /// are still possible though, if you have called ClearPassword(). | |||
/// | /// | |||
/// It is valid to call Reconnect() without ever calling Connect(), | /// It is valid to call Reconnect() without ever calling Connect(), | |||
End of changes. 5 change blocks. | ||||
6 lines changed or deleted | 14 lines changed or added | |||
controller.h | controller.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file controller.h | /// \file controller.h | |||
/// High level BlackBerry API class | /// High level BlackBerry API class | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
See the GNU General Public License in the COPYING file at the | See the GNU General Public License in the COPYING file at the | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __BARRY_CONTROLLER_H__ | #ifndef __BARRY_CONTROLLER_H__ | |||
#define __BARRY_CONTROLLER_H__ | #define __BARRY_CONTROLLER_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include "usbwrap.h" | ||||
#include "socket.h" | #include "socket.h" | |||
#include "pin.h" | ||||
#include "probe.h" | ||||
/// Project namespace, containing all related functions and classes. | /// Project namespace, containing all related functions and classes. | |||
/// This is the only namespace applications should be concerned with, | /// This is the only namespace applications should be concerned with, | |||
/// for now. | /// for now. | |||
namespace Barry { | namespace Barry { | |||
// forward declarations | // forward declarations | |||
class SocketRoutingQueue; | class SocketRoutingQueue; | |||
class ProbeResult; | ||||
class PrivateControllerData; | ||||
namespace Mode { | namespace Mode { | |||
class Mode; | class Mode; | |||
class IpModem; | class IpModem; | |||
class Serial; | class Serial; | |||
class JavaLoader; | class JavaLoader; | |||
class JVMDebug; | class JVMDebug; | |||
class RawChannel; | class RawChannel; | |||
} | } | |||
skipping to change at line 95 | skipping to change at line 95 | |||
Desktop, //< desktop mode required for databa se | Desktop, //< desktop mode required for databa se | |||
//< operation | //< operation | |||
JavaLoader, //< experimental | JavaLoader, //< experimental | |||
JVMDebug, //< experimental | JVMDebug, //< experimental | |||
UsbSerData, //< GPRS modem support over USB | UsbSerData, //< GPRS modem support over USB | |||
UsbSerCtrl, //< internally used behind the scene s | UsbSerCtrl, //< internally used behind the scene s | |||
RawChannel //< raw channel | RawChannel //< raw channel | |||
}; | }; | |||
private: | private: | |||
ProbeResult m_result; | std::auto_ptr<PrivateControllerData> m_priv; | |||
Usb::Device m_dev; | ||||
Usb::Interface *m_iface; | ||||
Pin m_pin; | ||||
SocketZero m_zero; | ||||
SocketRoutingQueue *m_queue; //< ptr to external object; no delet | ||||
e | ||||
private: | private: | |||
void SetupUsb(const ProbeResult &device); | void SetupUsb(const ProbeResult &device); | |||
protected: | protected: | |||
uint16_t SelectMode(ModeType mode); // returns mode socket | uint16_t SelectMode(ModeType mode); // returns mode socket | |||
uint16_t SelectMode(ModeType mode, const char *explicitModeName); // returns mode socket | uint16_t SelectMode(ModeType mode, const char *explicitModeName); // returns mode socket | |||
SocketHandle OpenSocket(uint16_t socket, const char *password = 0); | ||||
PrivateControllerData* GetPrivate() { return m_priv.get(); } | ||||
public: | public: | |||
explicit Controller(const ProbeResult &device, | explicit Controller(const ProbeResult &device, | |||
int default_timeout = USBWRAP_DEFAULT_TIMEOUT); | int default_timeout = USBWRAP_DEFAULT_TIMEOUT); | |||
Controller(const ProbeResult &device, SocketRoutingQueue &queue, | Controller(const ProbeResult &device, SocketRoutingQueue &queue, | |||
int default_timeout = USBWRAP_DEFAULT_TIMEOUT); | int default_timeout = USBWRAP_DEFAULT_TIMEOUT); | |||
~Controller(); | ~Controller(); | |||
bool HasQueue() const { return m_queue; } | bool HasQueue() const; | |||
SocketRoutingQueue* GetQueue(); // FIXME - not really ideal to have | ||||
// this exposed, but oh well | ||||
const ProbeResult& GetProbeResult() const { return m_result; } | const ProbeResult& GetProbeResult() const; | |||
}; | }; | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 8 change blocks. | ||||
14 lines changed or deleted | 11 lines changed or added | |||
data.h | data.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file data.h | /// \file data.h | |||
/// Class to deal with pre-saved data files | /// Class to deal with pre-saved data files | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 35 | skipping to change at line 35 | |||
#include "dll.h" | #include "dll.h" | |||
#include <iosfwd> | #include <iosfwd> | |||
#include <vector> | #include <vector> | |||
#include <string> | #include <string> | |||
#include <stdint.h> | #include <stdint.h> | |||
namespace Barry { | namespace Barry { | |||
class BXEXPORT Data | class BXEXPORT Data | |||
{ | { | |||
unsigned char *m_data; | unsigned char *m_memBlock; //< pointer to full memory block | |||
size_t m_bufsize; //< size of m_data buffer allocated | //< can be null if external | |||
size_t m_datasize; //< number of bytes of actual data | size_t m_blockSize; //< size of m_memBlock buffer alloca | |||
int m_endpoint; | ted | |||
unsigned char *m_dataStart; //< pointer to start of internal dat | ||||
a | ||||
//< can be null if external, and can | ||||
//< start somewhere in the middle of | ||||
//< m_memBlock if internal with a | ||||
//< prepend buffer | ||||
size_t m_dataSize; //< number of bytes of actual data | ||||
// copy on write feature | // copy on write feature | |||
const unsigned char *m_externalData; | const unsigned char *m_externalData; | |||
bool m_external; | bool m_external; | |||
// meta data | ||||
int m_endpoint; | ||||
// output format flags | // output format flags | |||
static bool bPrintAscii; | static bool bPrintAscii; | |||
protected: | protected: | |||
void MakeSpace(size_t desiredsize); | void MakeSpace(size_t desiredsize, size_t desiredprepend = 0); | |||
void CopyOnWrite(size_t desiredsize); | size_t AvailablePrependSpace() const; | |||
public: | public: | |||
Data(); | Data(); | |||
explicit Data(int endpoint, size_t startsize = 0x4000); | explicit Data(int endpoint, size_t startsize = 0x4000, size_t prepen dsize = 0x100); | |||
Data(const void *ValidData, size_t size); | Data(const void *ValidData, size_t size); | |||
Data(const Data &other); | Data(const Data &other); | |||
~Data(); | ~Data(); | |||
void InputHexLine(std::istream &is); | void InputHexLine(std::istream &is); | |||
void DumpHexLine(std::ostream &os, size_t index, size_t size) const; | void DumpHexLine(std::ostream &os, size_t index, size_t size) const; | |||
void DumpHex(std::ostream &os) const; | void DumpHex(std::ostream &os) const; | |||
int GetEndpoint() const { return m_endpoint; } | int GetEndpoint() const { return m_endpoint; } | |||
const unsigned char * GetData() const { return m_external ? m_extern | const unsigned char * GetData() const { return m_external ? m_extern | |||
alData : m_data; } | alData : m_dataStart; } | |||
size_t GetSize() const { return m_datasize; } | size_t GetSize() const { return m_dataSize; } | |||
unsigned char * GetBuffer(size_t requiredsize = 0); | unsigned char * GetBuffer(size_t requiredsize = 0); | |||
size_t GetBufSize() const { return m_bufsize; } | /// Returns size of buffer returned by GetBuffer() | |||
size_t GetBufSize() const; | ||||
void ReleaseBuffer(int datasize = -1); | void ReleaseBuffer(int datasize = -1); | |||
void AppendHexString(const char *str); | void AppendHexString(const char *str); | |||
/// set buffer to 0 size, but don't bother overwriting memory with 0 | /// set buffer to 0 size, but don't bother overwriting memory with 0 | |||
void QuickZap() { m_datasize = 0; } | void QuickZap() { m_dataSize = 0; } | |||
void Zap(); // does a memset too | void Zap(); // does a memset too | |||
Data& operator=(const Data &other); | Data& operator=(const Data &other); | |||
// | // | |||
// Utility functions | // Utility functions | |||
// | // | |||
// Writing data... basically does a memcpy(dst,src,sizeof(src)) | // Writing data... basically does a memcpy(dst,src,sizeof(src)) | |||
// for each type. Does no endian conversions. | // for each type. Does no endian conversions. | |||
// dst is calculated as buffer + offset. | // dst is calculated as buffer + offset. | |||
// The buffer is expanded automatically if needed. | // The buffer is expanded automatically if needed. | |||
// The offset is advanced by the size of the data. | // The offset is advanced by the size of the data. | |||
// GetSize() will increase automatically if the result of | ||||
// the MemCpy() goes beyond the existing data size. | ||||
// | // | |||
void MemCpy(size_t &offset, const void *src, size_t size); | void MemCpy(size_t &offset, const void *src, size_t size); | |||
void Append(const void *buf, size_t size); | void Append(const void *buf, size_t size); | |||
void Prepend(const void *buf, size_t size); | ||||
void Prechop(size_t size); | ||||
template <class ValueT> | template <class ValueT> | |||
void SetValue(size_t &offset, ValueT value) | void SetValue(size_t &offset, ValueT value) | |||
{ | { | |||
this->MemCpy(offset, &value, sizeof(value)); | this->MemCpy(offset, &value, sizeof(value)); | |||
} | } | |||
// static functions | // static functions | |||
static void PrintAscii(bool setting) { bPrintAscii = setting; } | static void PrintAscii(bool setting) { bPrintAscii = setting; } | |||
static bool PrintAscii() { return bPrintAscii; } | static bool PrintAscii() { return bPrintAscii; } | |||
}; | }; | |||
skipping to change at line 177 | skipping to change at line 192 | |||
Data *m_localData; | Data *m_localData; | |||
// the data block to use... could be external or internal, | // the data block to use... could be external or internal, | |||
// and does not change for the life of the object | // and does not change for the life of the object | |||
Data &m_data; | Data &m_data; | |||
public: | public: | |||
/// Default constructor, constructs an empty local Data object | /// Default constructor, constructs an empty local Data object | |||
DBData(); | DBData(); | |||
/// Copy constructor - always creates an internal Data object, and | ||||
/// uses Data object's copy constructor to make it. | ||||
/// Copies all meta data as well. | ||||
/// If you want to optimize the copy, use one of the constructors | ||||
/// below. | ||||
DBData(const DBData &other); | ||||
/// Constructs a local Data object that points to external memory | /// Constructs a local Data object that points to external memory | |||
DBData(const void *ValidData, size_t size); | DBData(const void *ValidData, size_t size); | |||
DBData(RecordFormatVersion ver, const std::string &dbName, | DBData(RecordFormatVersion ver, const std::string &dbName, | |||
uint8_t recType, uint32_t uniqueId, size_t offset, | uint8_t recType, uint32_t uniqueId, size_t offset, | |||
const void *ValidData, size_t size); | const void *ValidData, size_t size); | |||
/// If copy == false, constructs an external Data object, no local. | /// If copy == false, constructs an external Data object, no local. | |||
/// If copy == true, constructs an internal Data object copy | /// If copy == true, constructs an internal Data object copy | |||
/// For speed, set copy to false. | /// For speed, set copy to false. | |||
/// If you want Copy On Write behaviour, similar to Data(buf,size), | /// If you want Copy On Write behaviour, similar to Data(buf,size), | |||
End of changes. 11 change blocks. | ||||
13 lines changed or deleted | 37 lines changed or added | |||
dataqueue.h | dataqueue.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file dataqueue.h | /// \file dataqueue.h | |||
/// FIFO queue of Data objects | /// FIFO queue of Data objects | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2007-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2007-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
See the GNU General Public License in the COPYING file at the | See the GNU General Public License in the COPYING file at the | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __BARRY_DATAQUEUE_H__ | #ifndef __BARRY_DATAQUEUE_H__ | |||
#define __BARRY_DATAQUEUE_H__ | #define __BARRY_DATAQUEUE_H__ | |||
#include <queue> | #include <list> | |||
#include <pthread.h> | #include <pthread.h> | |||
#include <iosfwd> | ||||
namespace Barry { | namespace Barry { | |||
class Data; | class Data; | |||
// | // | |||
// DataQueue class | // DataQueue class | |||
// | // | |||
/// This class provides a thread aware fifo queue for Data objects, | /// This class provides a thread aware fifo queue for Data objects, | |||
/// providing memory management for all Data object pointers it contains. | /// providing memory management for all Data object pointers it contains. | |||
/// | /// | |||
/// It uses similar member names as std::queue<>, for consistency. | /// It uses similar member names as std::queue<>, for consistency. | |||
/// | /// | |||
class DataQueue | class DataQueue | |||
{ | { | |||
typedef std::queue<Data*> queue_type; | // always use the raw_push() and raw_pop() functions | |||
typedef std::list<Data*> queue_type; | ||||
pthread_mutex_t m_waitMutex; | pthread_mutex_t m_waitMutex; | |||
pthread_cond_t m_waitCond; | pthread_cond_t m_waitCond; | |||
mutable pthread_mutex_t m_accessMutex; // locked for each access of m_queue | mutable pthread_mutex_t m_accessMutex; // locked for each access of m_queue | |||
queue_type m_queue; | queue_type m_queue; | |||
protected: | ||||
void raw_push(Data *data); | ||||
Data* raw_pop(); | ||||
public: | public: | |||
DataQueue(); | DataQueue(); | |||
~DataQueue(); // frees all data in the queue | ~DataQueue(); // frees all data in the queue | |||
// Pushes data into the end of the queue. | // Pushes data into the end of the queue. | |||
// The queue owns this pointer as soon as the function is | // The queue owns this pointer as soon as the function is | |||
// called. In the case of an exception, it will be freed. | // called. In the case of an exception, it will be freed. | |||
// Performs a thread broadcast once new data has been added. | // Performs a thread broadcast once new data has been added. | |||
void push(Data *data); | void push(Data *data); | |||
skipping to change at line 81 | skipping to change at line 87 | |||
// Pops all data from other and appends it to this. | // Pops all data from other and appends it to this. | |||
// After calling this function, other will be empty, and | // After calling this function, other will be empty, and | |||
// this will contain all its data. | // this will contain all its data. | |||
// In the case of an exception, any uncopied data will | // In the case of an exception, any uncopied data will | |||
// remain in other. | // remain in other. | |||
void append_from(DataQueue &other); | void append_from(DataQueue &other); | |||
bool empty() const; // return true if empty | bool empty() const; // return true if empty | |||
size_t size() const; | size_t size() const; | |||
void DumpAll(std::ostream &os) const; | ||||
}; | }; | |||
inline std::ostream& operator<< (std::ostream &os, const DataQueue &dq) | ||||
{ | ||||
dq.DumpAll(os); | ||||
return os; | ||||
} | ||||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 7 change blocks. | ||||
3 lines changed or deleted | 17 lines changed or added | |||
dll.h | dll.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file dll.h | /// \file dll.h | |||
/// Macros for handling DLL/library API visibility | /// Macros for handling DLL/library API visibility | |||
/// | /// | |||
/// Based on documentation at: http://gcc.gnu.org/wiki/Visibility | /// Based on documentation at: http://gcc.gnu.org/wiki/Visibility | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
error.h | error.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file error.h | /// \file error.h | |||
/// Common exception classes for the Barry library | /// Common exception classes for the Barry library | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 78 | skipping to change at line 78 | |||
bool out_of_tries) | bool out_of_tries) | |||
: Barry::Error(str), | : Barry::Error(str), | |||
m_remaining_tries(remaining_tries), | m_remaining_tries(remaining_tries), | |||
m_out_of_tries(out_of_tries) | m_out_of_tries(out_of_tries) | |||
{} | {} | |||
int remaining_tries() const { return m_remaining_tries; } | int remaining_tries() const { return m_remaining_tries; } | |||
bool out_of_tries() const { return m_out_of_tries; } | bool out_of_tries() const { return m_out_of_tries; } | |||
}; | }; | |||
// | // | |||
// SocketCloseOnOpen | ||||
// | ||||
/// Thrown by the Socket class if it receives a CLOSE message in | ||||
/// response to an OPEN command. This can mean a number of things: | ||||
/// | ||||
/// - device is password protected, and the wrong password was given | ||||
/// - device thinks that the socket is already open | ||||
/// | ||||
/// This special exception thrown so the application can try again | ||||
/// with a fresh Socket::Open() call. | ||||
/// | ||||
class BXEXPORT SocketCloseOnOpen : public Barry::Error | ||||
{ | ||||
public: | ||||
SocketCloseOnOpen(const std::string &str) : Barry::Error(str) {} | ||||
}; | ||||
// | ||||
// PinNotFound | // PinNotFound | |||
// | // | |||
/// Thrown by the Connector class when unable to find the requested Pin | /// Thrown by the Connector class when unable to find the requested Pin | |||
/// If the attached pin is not Valid(), then unable to autodetect device. | /// If the attached pin is not Valid(), then unable to autodetect device. | |||
/// If pin is Valid(), then the specified pin number was not available. | /// If pin is Valid(), then the specified pin number was not available. | |||
/// probe_count is the number of devices found during the probe. | /// probe_count is the number of devices found during the probe. | |||
/// | /// | |||
class BXEXPORT PinNotFound : public Barry::Error | class BXEXPORT PinNotFound : public Barry::Error | |||
{ | { | |||
Barry::Pin m_pin; | Barry::Pin m_pin; | |||
skipping to change at line 249 | skipping to change at line 267 | |||
// | // | |||
/// Thrown by the Restore builder class when there is a problem with the | /// Thrown by the Restore builder class when there is a problem with the | |||
/// low level file operation. | /// low level file operation. | |||
/// | /// | |||
class BXEXPORT RestoreError : public Barry::Error | class BXEXPORT RestoreError : public Barry::Error | |||
{ | { | |||
public: | public: | |||
RestoreError(const std::string &str) : Error(str) {} | RestoreError(const std::string &str) : Error(str) {} | |||
}; | }; | |||
// | ||||
// ReturnCodeError | ||||
// | ||||
/// Thrown by the Mode::Desktop class when a database command returns | ||||
/// a non-zero error code. Can happen when writing or clearing a database. | ||||
/// The packet command and return code are passed along, for examination | ||||
/// by application code. Note that return code 0x02 usually means | ||||
/// you're trying to clear or write to a read-only database, like Time Zone | ||||
s. | ||||
/// | ||||
class BXEXPORT ReturnCodeError : public Barry::Error | ||||
{ | ||||
unsigned int m_command, m_return_code; | ||||
public: | ||||
ReturnCodeError(const std::string &str, unsigned int command, | ||||
unsigned int return_code) | ||||
: Error(str) | ||||
, m_command(command) | ||||
, m_return_code(return_code) | ||||
{ | ||||
} | ||||
unsigned int command() const { return m_command; } | ||||
unsigned int return_code() const { return m_return_code; } | ||||
bool IsReadOnly() const { return return_code() == 0x02; } | ||||
}; | ||||
// | ||||
// ValidationError | ||||
// | ||||
/// Thrown by one of the record classes' Validate() function. Contains | ||||
/// and error message describing the deficiency. | ||||
/// | ||||
class BXEXPORT ValidationError : public Barry::Error | ||||
{ | ||||
public: | ||||
explicit ValidationError(const std::string &str) | ||||
: Error(str) | ||||
{ | ||||
} | ||||
}; | ||||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 63 lines changed or added | |||
iconv.h | iconv.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file iconv.h | /// \file iconv.h | |||
/// iconv wrapper class, and pluggable interface for records | /// iconv wrapper class, and pluggable interface for records | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
See the GNU General Public License in the COPYING file at the | See the GNU General Public License in the COPYING file at the | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __BARRY_ICONV_H__ | #ifndef __BARRY_ICONV_H__ | |||
#define __BARRY_ICONV_H__ | #define __BARRY_ICONV_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include "data.h" | #include "data.h" | |||
#include <iconv.h> | ||||
#include <string> | #include <string> | |||
#include <memory> | ||||
namespace Barry { | namespace Barry { | |||
class IConverter; | class IConverter; | |||
class IConvHandlePrivate; | ||||
// | // | |||
// IConvHandle class | // IConvHandle class | |||
// | // | |||
/// Wrapper class for a two-way iconv_t handle pair. Automatically | /// Wrapper class for a two-way iconv_t handle pair. Automatically | |||
/// handles closing in the destructor. | /// handles closing in the destructor. | |||
// | // | |||
class BXEXPORT IConvHandle | class BXEXPORT IConvHandle | |||
{ | { | |||
friend class IConverter; | friend class IConverter; | |||
iconv_t m_handle; | std::auto_ptr<IConvHandlePrivate> m_priv; | |||
bool m_throw_on_conv_err; | ||||
private: | private: | |||
// no copying | ||||
IConvHandle(const IConvHandle &other); | ||||
IConvHandle& operator=(const IConvHandle &other); | ||||
// private constructor, used only by IConverter | // private constructor, used only by IConverter | |||
IConvHandle(const char *fromcode, const char *tocode); | IConvHandle(const char *fromcode, const char *tocode, bool throwable | |||
); | ||||
// the heart of the conversion | ||||
std::string Convert(Data &tmp, const std::string &str) const; | ||||
public: | public: | |||
// custom conversions from any to IConverter's 'tocode' | // custom conversions from any to IConverter's 'tocode' | |||
IConvHandle(const char *fromcode, const IConverter &ic); | IConvHandle(const char *fromcode, const IConverter &ic, | |||
bool throw_on_conv_err = false); | ||||
// custom conversions from IConverter's 'tocode' to any | // custom conversions from IConverter's 'tocode' to any | |||
IConvHandle(const IConverter &ic, const char *tocode); | IConvHandle(const IConverter &ic, const char *tocode, | |||
bool throw_on_conv_err = false); | ||||
~IConvHandle(); | ~IConvHandle(); | |||
}; | }; | |||
// | // | |||
// IConverter | // IConverter | |||
// | // | |||
/// Main charset conversion class, primarily focused on converting | /// Main charset conversion class, primarily focused on converting | |||
/// between the Blackberry charset and an application-specified one. | /// between the Blackberry charset and an application-specified one. | |||
/// Additional conversions are possible through custom IConvHandle, | /// Additional conversions are possible through custom IConvHandle, | |||
/// but the goal of this class design is to deal with _one_ | /// but the goal of this class design is to deal with _one_ | |||
skipping to change at line 97 | skipping to change at line 109 | |||
{ | { | |||
friend class IConvHandle; | friend class IConvHandle; | |||
IConvHandle m_from; | IConvHandle m_from; | |||
IConvHandle m_to; | IConvHandle m_to; | |||
std::string m_tocode; | std::string m_tocode; | |||
// internal buffer for fast conversions | // internal buffer for fast conversions | |||
mutable Data m_buffer; | mutable Data m_buffer; | |||
bool m_throw_on_conv_err; | ||||
private: | ||||
std::string Convert(iconv_t cd, const std::string &str) const; | ||||
public: | public: | |||
/// Always throws ErrnoError if unable to open iconv. | /// Always throws ErrnoError if unable to open iconv. | |||
/// If throw_on_conv_err is true, then string conversion operations | /// If throw_on_conv_err is true, then string conversion operations | |||
/// that fail will also throw ErrnoError. | /// that fail will also throw ErrnoError. | |||
explicit IConverter(const char *tocode = "UTF-8", bool throw_on_conv | explicit IConverter(const char *tocode = "UTF-8", | |||
_err = false); | bool throw_on_conv_err = false); | |||
~IConverter(); | ~IConverter(); | |||
std::string FromBB(const std::string &str) const; | std::string FromBB(const std::string &str) const; | |||
std::string ToBB(const std::string &str) const; | std::string ToBB(const std::string &str) const; | |||
// Custom override functions, meant for converting between | // Custom override functions, meant for converting between | |||
// non-BLACKBERRY_CHARSET charsets and the tocode set by the | // non-BLACKBERRY_CHARSET charsets and the tocode set by the | |||
// IConverter constructor | // IConverter constructor | |||
std::string Convert(const IConvHandle &custom, const std::string &st r) const; | std::string Convert(const IConvHandle &custom, const std::string &st r) const; | |||
}; | }; | |||
End of changes. 11 change blocks. | ||||
13 lines changed or deleted | 21 lines changed or added | |||
j_server.h | j_server.h | |||
---|---|---|---|---|
skipping to change at line 95 | skipping to change at line 95 | |||
void SetPasswordDevice(std::string password); | void SetPasswordDevice(std::string password); | |||
void SetConsoleCallback(ConsoleCallbackType callback); | void SetConsoleCallback(ConsoleCallbackType callback); | |||
bool Start(); // starts new thread | bool Start(); // starts new thread | |||
bool AcceptConnection(); | bool AcceptConnection(); | |||
bool AttachToDevice(); | bool AttachToDevice(); | |||
bool InitVisibleClassList(); | bool InitVisibleClassList(); | |||
bool Hello(); | bool Hello(); | |||
void Run(); | void Run(volatile bool &stopflag); | |||
void DetachFromDevice(); | void DetachFromDevice(); | |||
bool Stop(); // cancels thread if still running, and | bool Stop(); // cancels thread if still running, and | |||
// cleans up Start() | // cleans up Start() | |||
}; | }; | |||
}} // namespace Barry::JDWP | }} // namespace Barry::JDWP | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
ldif.h | ldif.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file ldif.h | /// \file ldif.h | |||
/// Routines for reading and writing LDAP LDIF data. | /// Routines for reading and writing LDAP LDIF data. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
ldifio.h | ldifio.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file ldifio.h | /// \file ldifio.h | |||
/// Storage, parser, and builder classes for ldif operations. | /// Storage, parser, and builder classes for ldif operations. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
log.h | log.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file log.h | /// \file log.h | |||
/// General header for the Barry library | /// General header for the Barry library | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
m_desktop.h | m_desktop.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file m_desktop.h | /// \file m_desktop.h | |||
/// Mode class for the Desktop mode | /// Mode class for the Desktop mode | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
m_desktoptmpl.h | m_desktoptmpl.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file m_desktoptmpl.h | /// \file m_desktoptmpl.h | |||
/// Ease of use templates for the Desktop mode class | /// Ease of use templates for the Desktop mode class | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 54 | skipping to change at line 54 | |||
void Desktop::SaveDatabaseByType(StorageT &store) | void Desktop::SaveDatabaseByType(StorageT &store) | |||
{ | { | |||
unsigned int dbId = this->GetDBID( RecordT::GetDBName() ); | unsigned int dbId = this->GetDBID( RecordT::GetDBName() ); | |||
Barry::RecordBuilder<RecordT, StorageT> build(store); | Barry::RecordBuilder<RecordT, StorageT> build(store); | |||
SaveDatabase(dbId, build); | SaveDatabase(dbId, build); | |||
} | } | |||
template <class StorageT> | template <class StorageT> | |||
void Desktop::LoadDatabaseByName(const std::string &name, StorageT &store) | void Desktop::LoadDatabaseByName(const std::string &name, StorageT &store) | |||
{ | { | |||
if( name == Contact::GetDBName() ) | #undef HANDLE_PARSER | |||
LoadDatabaseByType<Contact>(store); | #define HANDLE_PARSER(rtype) \ | |||
else if( name == Message::GetDBName() ) | else if( name == Barry::rtype::GetDBName() ) \ | |||
LoadDatabaseByType<Message>(store); | LoadDatabaseByType<rtype>(store); | |||
else if( name == Calendar::GetDBName() ) | ||||
LoadDatabaseByType<Calendar>(store); | if( !name.size() ) | |||
else if( name == CalendarAll::GetDBName() ) | throw Error("Empty database name in LoadDatabaseByName"); | |||
LoadDatabaseByType<CalendarAll>(store); | ALL_KNOWN_PARSER_TYPES | |||
else | else | |||
throw Error("Unknown database name in LoadDatabaseByName: " + name); | throw Error("Unknown database name in LoadDatabaseByName: " + name); | |||
} | } | |||
template <class StorageT> | template <class StorageT> | |||
void Desktop::SaveDatabaseByName(const std::string &name, StorageT &store) | void Desktop::SaveDatabaseByName(const std::string &name, StorageT &store) | |||
{ | { | |||
if( name == Contact::GetDBName() ) | #undef HANDLE_BUILDER | |||
SaveDatabaseByType<Contact>(store); | #define HANDLE_BUILDER(rtype) \ | |||
else if( name == Message::GetDBName() ) | else if( name == Barry::rtype::GetDBName() ) \ | |||
SaveDatabaseByType<Message>(store); | SaveDatabaseByType<rtype>(store); | |||
else if( name == Calendar::GetDBName() ) | ||||
SaveDatabaseByType<Calendar>(store); | if( !name.size() ) | |||
else if( name == CalendarAll::GetDBName() ) | throw Error("Empty database name in SaveDatabaseByName"); | |||
SaveDatabaseByType<CalendarAll>(store); | ALL_KNOWN_BUILDER_TYPES | |||
else | else | |||
throw Error("Unknown database name in SaveDatabaseByName: " + name); | throw Error("Unknown database name in SaveDatabaseByName: " + name); | |||
} | } | |||
template <class RecordT> | template <class RecordT> | |||
void Desktop::AddRecordByType(uint32_t recordId, const RecordT &rec) | void Desktop::AddRecordByType(uint32_t recordId, const RecordT &rec) | |||
{ | { | |||
unsigned int dbId = this->GetDBID( RecordT::GetDBName() ); | unsigned int dbId = this->GetDBID( RecordT::GetDBName() ); | |||
// FIXME - I know this is a convenience template, but it still | // FIXME - I know this is a convenience template, but it still | |||
// hurts making a temporary copy just to set the record ID... | // hurts making a temporary copy just to set the record ID... | |||
End of changes. 3 change blocks. | ||||
17 lines changed or deleted | 17 lines changed or added | |||
m_ipmodem.h | m_ipmodem.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file m_ipmodem.h | /// \file m_ipmodem.h | |||
/// Mode class for GPRS modem mode (using endpoints on | /// Mode class for GPRS modem mode (using endpoints on | |||
/// modern devices) | /// modern devices) | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
m_javaloader.h | m_javaloader.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file m_javaloader.h | /// \file m_javaloader.h | |||
/// Mode class for the JavaLoader mode | /// Mode class for the JavaLoader mode | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2008-2009, Nicolas VIVIEN | Copyright (C) 2008-2009, Nicolas VIVIEN | |||
Some parts are inspired from m_desktop.h | Some parts are inspired from m_desktop.h | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
skipping to change at line 30 | skipping to change at line 30 | |||
See the GNU General Public License in the COPYING file at the | See the GNU General Public License in the COPYING file at the | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __BARRY_M_JAVALOADER_H__ | #ifndef __BARRY_M_JAVALOADER_H__ | |||
#define __BARRY_M_JAVALOADER_H__ | #define __BARRY_M_JAVALOADER_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include "m_mode_base.h" | #include "m_mode_base.h" | |||
#include "socket.h" | ||||
#include "record.h" | ||||
#include "data.h" | #include "data.h" | |||
#include "pin.h" | #include "pin.h" | |||
namespace Barry { | namespace Barry { | |||
// forward declarations | // forward declarations | |||
class Parser; | class Parser; | |||
class Builder; | class Builder; | |||
class Controller; | class Controller; | |||
class CodFileBuilder; | class CodFileBuilder; | |||
End of changes. 2 change blocks. | ||||
3 lines changed or deleted | 1 lines changed or added | |||
m_jvmdebug.h | m_jvmdebug.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file m_jvmdebug.h | /// \file m_jvmdebug.h | |||
/// Mode class for the JVMDebug mode | /// Mode class for the JVMDebug mode | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2008-2009, Nicolas VIVIEN | Copyright (C) 2008-2009, Nicolas VIVIEN | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
m_mode_base.h | m_mode_base.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file m_mode_base.h | /// \file m_mode_base.h | |||
/// Base for mode classes | /// Base for mode classes | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
m_raw_channel.h | m_raw_channel.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file m_raw_channel.h | /// \file m_raw_channel.h | |||
/// Mode class for a raw channel | /// Mode class for a raw channel | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Portions Copyright (C) 2010 RealVNC Ltd. | Portions Copyright (C) 2010 RealVNC Ltd. | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 79 | skipping to change at line 79 | |||
/// object during construction | /// object during construction | |||
/// - Call Open() to open the channel and finish constructing. | /// - Call Open() to open the channel and finish constructing. | |||
/// - Call GetData() to fetch data | /// - Call GetData() to fetch data | |||
/// - Call SendData() to send data | /// - Call SendData() to send data | |||
/// | /// | |||
class BXEXPORT RawChannel : public Mode | class BXEXPORT RawChannel : public Mode | |||
{ | { | |||
friend class RawChannelSocketHandler; | friend class RawChannelSocketHandler; | |||
friend class RawChannelZeroSocketHandler; | friend class RawChannelZeroSocketHandler; | |||
// Mutex for signalling between read and write threads | ||||
pthread_mutex_t m_mutex; | ||||
bool m_mutex_valid; | ||||
// Condvar for signalling between read and write threads | ||||
pthread_cond_t m_cv; | ||||
bool m_cv_valid; | ||||
semaphore *m_semaphore; | ||||
RawChannelDataCallback *m_callback; | RawChannelDataCallback *m_callback; | |||
unsigned char *m_send_buffer; | unsigned char *m_send_buffer; | |||
bool m_zero_registered; | bool m_zero_registered; | |||
std::string *m_pending_error; | std::string *m_pending_error; | |||
Data m_receive_data; | Data m_receive_data; | |||
protected: | protected: | |||
void CheckQueueAvailable(); | void CheckQueueAvailable(); | |||
void InitBuffer(); | void InitBuffer(); | |||
void InitSemaphore(); | ||||
void SetPendingError(const char *msg); | void SetPendingError(const char *msg); | |||
void UnregisterZeroSocketInterest(); | void UnregisterZeroSocketInterest(); | |||
// Used to validate a packet is a valid channel data packet | // Used to validate a packet is a valid channel data packet | |||
void ValidateDataPacket(Data &data); | void ValidateDataPacket(Data &data); | |||
// Not intended for use by users of this class. | // Not intended for use by users of this class. | |||
// Used for handling zero-socket packets. | // Used for handling zero-socket packets. | |||
void HandleReceivedZeroPacket(Data &data); | void HandleReceivedZeroPacket(Data &data); | |||
End of changes. 3 change blocks. | ||||
10 lines changed or deleted | 1 lines changed or added | |||
m_serial.h | m_serial.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file m_serial.h | /// \file m_serial.h | |||
/// Mode class for serial / GPRS modem mode | /// Mode class for serial / GPRS modem mode | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
mimeio.h | mimeio.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file mimeio.h | /// \file mimeio.h | |||
/// Storage, parser, builder classes for MIME objects | /// Storage, parser, builder classes for MIME objects | |||
/// (vcard, vevent, vtodo, vjournal) | /// (vcard, vevent, vtodo, vjournal) | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
modem.h | modem.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file modem.h | /// \file modem.h | |||
/// Modem API base class for the various serial/modem | /// Modem API base class for the various serial/modem | |||
/// modes available on the Blackberry. | /// modes available on the Blackberry. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
parser.h | parser.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file parser.h | /// \file parser.h | |||
/// Virtual parser wrapper | /// Virtual parser wrapper | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 48 | skipping to change at line 48 | |||
class CalendarAll; | class CalendarAll; | |||
class CallLog; | class CallLog; | |||
class Bookmark; | class Bookmark; | |||
class ServiceBook; | class ServiceBook; | |||
class Memo; | class Memo; | |||
class Task; | class Task; | |||
class PINMessage; | class PINMessage; | |||
class SavedMessage; | class SavedMessage; | |||
class Sms; | class Sms; | |||
class Folder; | class Folder; | |||
class Timezone; | class TimeZone; | |||
class ContentStore; | class ContentStore; | |||
class HandheldAgent; | ||||
} | } | |||
// | // | |||
// This macro can be used to automatically generate code for all known | // This macro can be used to automatically generate code for all known | |||
// record types. Just #undef HANDLE_PARSER, then #define it to whatever | // record types. Just #undef HANDLE_PARSER, then #define it to whatever | |||
// you need, then use ALL_KNOWN_PARSER_TYPES. See parser.cc for | // you need, then use ALL_KNOWN_PARSER_TYPES. See parser.cc for | |||
// various examples. | // various examples. | |||
// | // | |||
// These are sorted so their GetDBName()'s will display in alphabetical ord er. | // These are sorted so their GetDBName()'s will display in alphabetical ord er. | |||
// | // | |||
#define ALL_KNOWN_PARSER_TYPES \ | #define ALL_KNOWN_PARSER_TYPES \ | |||
HANDLE_PARSER(Contact) \ | HANDLE_PARSER(Contact) \ | |||
HANDLE_PARSER(Bookmark) \ | HANDLE_PARSER(Bookmark) \ | |||
HANDLE_PARSER(Calendar) \ | HANDLE_PARSER(Calendar) \ | |||
HANDLE_PARSER(CalendarAll) \ | HANDLE_PARSER(CalendarAll) \ | |||
HANDLE_PARSER(ContentStore) \ | HANDLE_PARSER(ContentStore) \ | |||
HANDLE_PARSER(Folder) \ | HANDLE_PARSER(Folder) \ | |||
HANDLE_PARSER(HandheldAgent) \ | ||||
HANDLE_PARSER(Memo) \ | HANDLE_PARSER(Memo) \ | |||
HANDLE_PARSER(Message) \ | HANDLE_PARSER(Message) \ | |||
HANDLE_PARSER(CallLog) \ | HANDLE_PARSER(CallLog) \ | |||
HANDLE_PARSER(PINMessage) \ | HANDLE_PARSER(PINMessage) \ | |||
HANDLE_PARSER(SavedMessage) \ | HANDLE_PARSER(SavedMessage) \ | |||
HANDLE_PARSER(ServiceBook) \ | HANDLE_PARSER(ServiceBook) \ | |||
HANDLE_PARSER(Sms) \ | HANDLE_PARSER(Sms) \ | |||
HANDLE_PARSER(Task) \ | HANDLE_PARSER(Task) \ | |||
HANDLE_PARSER(Timezone) | HANDLE_PARSER(TimeZone) | |||
namespace Barry { | namespace Barry { | |||
// | // | |||
// Parser class | // Parser class | |||
// | // | |||
/// Base class for the parser hierarchy. | /// Base class for the parser hierarchy. | |||
/// | /// | |||
/// This class provides the interface that the Controller class uses | /// This class provides the interface that the Controller class uses | |||
/// to pass raw data it reads from the device. The Controller, along | /// to pass raw data it reads from the device. The Controller, along | |||
skipping to change at line 214 | skipping to change at line 216 | |||
{ | { | |||
} | } | |||
void operator() (const RecordT &r) | void operator() (const RecordT &r) | |||
{ | { | |||
r.Dump(m_os); | r.Dump(m_os); | |||
} | } | |||
}; | }; | |||
// | // | |||
// RecordStore | ||||
// | ||||
/// A Storage class for RecordParser that stores a copy of the parsed recor | ||||
d. | ||||
/// | ||||
template <class RecordT> | ||||
class RecordStore | ||||
{ | ||||
public: | ||||
RecordT m_rec; | ||||
void operator() (const RecordT &r) | ||||
{ | ||||
m_rec = r; | ||||
} | ||||
}; | ||||
// | ||||
// ParseDBData | // ParseDBData | |||
// | // | |||
/// Contains the proper way to convert a DBData object into a record. | /// Contains the proper way to convert a DBData object into a record. | |||
/// | /// | |||
template <class RecordT> | template <class RecordT> | |||
void ParseDBData(const DBData &data, RecordT &rec, const IConverter *ic) | void ParseDBData(const DBData &data, RecordT &rec, const IConverter *ic) | |||
{ | { | |||
// start fresh | // start fresh | |||
rec = RecordT(); | rec = RecordT(); | |||
skipping to change at line 341 | skipping to change at line 360 | |||
return RecordT::GetDefaultRecType(); | return RecordT::GetDefaultRecType(); | |||
} | } | |||
// These functions depend on the parser having just parsed | // These functions depend on the parser having just parsed | |||
// a record successfully. | // a record successfully. | |||
virtual bool IsRecordValid() const | virtual bool IsRecordValid() const | |||
{ | { | |||
return m_record_valid; | return m_record_valid; | |||
} | } | |||
virtual const RecordT& GetRecord() const | ||||
{ | ||||
return m_rec; | ||||
} | ||||
virtual uint8_t GetRecType() const | virtual uint8_t GetRecType() const | |||
{ | { | |||
return m_rec.GetRecType(); | return m_rec.GetRecType(); | |||
} | } | |||
virtual uint32_t GetUniqueId() const | virtual uint32_t GetUniqueId() const | |||
{ | { | |||
return m_rec.GetUniqueId(); | return m_rec.GetUniqueId(); | |||
} | } | |||
End of changes. 7 change blocks. | ||||
3 lines changed or deleted | 28 lines changed or added | |||
pin.h | pin.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file pin.h | /// \file pin.h | |||
/// class for device PIN notation | /// class for device PIN notation | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2007-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2007-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
pipe.h | pipe.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file pipe.h | /// \file pipe.h | |||
/// Connector class to join parsers and builders together | /// Connector class to join parsers and builders together | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
pppfilter.h | pppfilter.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file pppfilter.h | /// \file pppfilter.h | |||
/// Data filter class, to morph PPP data into something that | /// Data filter class, to morph PPP data into something that | |||
/// the Blackberry / Rogers / ISP can handle. | /// the Blackberry / Rogers / ISP can handle. | |||
/// This logic is based partly on XmBlackBerry's | /// This logic is based partly on XmBlackBerry's | |||
/// gprs_protocol_fix.c program. | /// gprs_protocol_fix.c program. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
probe.h | probe.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file probe.h | /// \file probe.h | |||
/// USB Blackberry detection routines | /// USB Blackberry detection routines | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 40 | skipping to change at line 40 | |||
#include <stdint.h> | #include <stdint.h> | |||
namespace Barry { | namespace Barry { | |||
class Probe; | class Probe; | |||
struct BXEXPORT ProbeResult | struct BXEXPORT ProbeResult | |||
{ | { | |||
friend class Probe; | friend class Probe; | |||
Usb::DeviceIDType m_dev; | Usb::DeviceID m_dev; | |||
unsigned char m_interface; | unsigned char m_interface; | |||
unsigned char m_altsetting; | ||||
Barry::Pin m_pin; | Barry::Pin m_pin; | |||
Usb::EndpointPair m_ep; | Usb::EndpointPair m_ep; | |||
Usb::EndpointPair m_epModem; | Usb::EndpointPair m_epModem; | |||
// Specifies if it's necessary to clear halt on the | // Specifies if it's necessary to clear halt on the | |||
// endpoints before using them. On some devices such | // endpoints before using them. On some devices such | |||
// as the 8830 it's essential to clear halt. On other | // as the 8830 it's essential to clear halt. On other | |||
// devices such as the Curve 8520 calling clear halt | // devices such as the Curve 8520 calling clear halt | |||
// can cause them to get into a state where they drop | // can cause them to get into a state where they drop | |||
// packets. | // packets. | |||
bool m_needClearHalt; | bool m_needClearHalt; | |||
skipping to change at line 80 | skipping to change at line 81 | |||
ProbeResult() | ProbeResult() | |||
: m_dev(0), m_interface(0), m_pin(0) | : m_dev(0), m_interface(0), m_pin(0) | |||
, m_needClearHalt(false), m_needSetAltInterface(false) | , m_needClearHalt(false), m_needSetAltInterface(false) | |||
, m_zeroSocketSequence(0) | , m_zeroSocketSequence(0) | |||
{} | {} | |||
public: | public: | |||
void DumpAll(std::ostream &os) const; | void DumpAll(std::ostream &os) const; | |||
bool HasIpModem() const { return m_epModem.IsComplete(); } | bool HasIpModem() const { return m_epModem.IsComplete(); } | |||
std::string GetDisplayName() const; | ||||
bool operator==(const Barry::Pin &pin) const | bool operator==(const Barry::Pin &pin) const | |||
{ | { | |||
return m_pin == pin; | return m_pin == pin; | |||
} | } | |||
}; | }; | |||
BXEXPORT std::ostream& operator<< (std::ostream &os, const ProbeResult &pr) ; | BXEXPORT std::ostream& operator<< (std::ostream &os, const ProbeResult &pr) ; | |||
class BXEXPORT Probe | class BXEXPORT Probe | |||
{ | { | |||
public: | public: | |||
typedef std::vector<ProbeResult> Results; | typedef std::vector<ProbeResult> Results; | |||
enum LogExceptionBits { | ||||
LOG_BUSY = 0x0001, | ||||
LOG_ACCESS = 0x0002, | ||||
LOG_PERM = 0x0004 | ||||
}; | ||||
private: | private: | |||
Usb::DeviceList m_devices; | ||||
Results m_results; | Results m_results; | |||
unsigned int m_log_exceptions; | ||||
std::vector<std::string> m_fail_msgs; | std::vector<std::string> m_fail_msgs; | |||
int m_fail_count; | int m_fail_count; | |||
bool m_epp_override; | bool m_epp_override; | |||
Usb::EndpointPair m_epp; | Usb::EndpointPair m_epp; | |||
BXLOCAL bool CheckSize(const Data &data, unsigned int required); | BXLOCAL bool CheckSize(const Data &data, unsigned int required); | |||
BXLOCAL bool ParsePIN(const Data &data, uint32_t &pin); | BXLOCAL bool ParsePIN(const Data &data, uint32_t &pin); | |||
BXLOCAL bool ParseDesc(const Data &data, std::string &desc); | BXLOCAL bool ParseDesc(const Data &data, std::string &desc); | |||
protected: | protected: | |||
void ProbeMatching(int vendor, int product, | void ProbeMatching(int vendor, int product, | |||
const char *busname, const char *devname); | const char *busname, const char *devname); | |||
void ProbeDevice(Usb::DeviceIDType devid); | void ProbeDevice(Usb::DeviceID& devid); | |||
void ProbeDeviceEndpoints(Usb::Device &dev, Usb::EndpointDiscovery & | void ProbeDeviceEndpoints(Usb::Device &dev, Usb::EndpointPairings &e | |||
ed, ProbeResult &result); | d, ProbeResult &result); | |||
bool ProbePair(Usb::Device &dev, const Usb::EndpointPair &ep, | bool ProbePair(Usb::Device &dev, const Usb::EndpointPair &ep, | |||
uint32_t &pin, std::string &desc, uint8_t &zeroSocketSequenc e, | uint32_t &pin, std::string &desc, uint8_t &zeroSocketSequenc e, | |||
bool &needClearHalt); | bool &needClearHalt); | |||
bool ProbeModem(Usb::Device &dev, const Usb::EndpointPair &ep); | bool ProbeModem(Usb::Device &dev, const Usb::EndpointPair &ep); | |||
public: | public: | |||
/// log_exceptions is a bitmask of low level USB errors to | ||||
/// log instead of throw on. If 0, all USB errors will cause | ||||
/// an exception, and thereby stop the probe. If the error | ||||
/// is set in the bitmask, the exception will be caught, and | ||||
/// logged in m_fail_msgs, which can be retrieved through | ||||
/// GetFailCount() and GetFailMsg(). If auto_dump_log is true, | ||||
/// all logged messages will be dumped as well, via the eout() macro | ||||
, | ||||
/// to make sure they are seen, even if the application | ||||
/// programmer doesn't deal with them via the API. | ||||
Probe(const char *busname = 0, const char *devname = 0, | Probe(const char *busname = 0, const char *devname = 0, | |||
const Usb::EndpointPair *epp = 0); | const Usb::EndpointPair *epp = 0, | |||
unsigned int log_exceptions = LOG_BUSY | LOG_ACCESS | LOG_PE | ||||
RM, | ||||
bool auto_dump_log = true); | ||||
const Results& GetResults() const { return m_results; } | const Results& GetResults() const { return m_results; } | |||
int GetCount() const { return m_results.size(); } | int GetCount() const { return m_results.size(); } | |||
int GetFailCount() const { return m_fail_count; } | int GetFailCount() const { return m_fail_count; } | |||
const std::string& GetFailMsg(int index) const { return m_fail_msgs. at(index); } | const std::string& GetFailMsg(int index) const { return m_fail_msgs. at(index); } | |||
const ProbeResult& Get(int index) const { return m_results.at(index) ; } | const ProbeResult& Get(int index) const { return m_results.at(index) ; } | |||
int FindActive(Barry::Pin pin = 0) const; // returns -1 if pin not f ound | int FindActive(Barry::Pin pin = 0) const; // returns -1 if pin not f ound | |||
End of changes. 10 change blocks. | ||||
6 lines changed or deleted | 30 lines changed or added | |||
protocol.h | protocol.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file protocol.h | /// \file protocol.h | |||
/// USB Blackberry bulk protocol API constants | /// USB Blackberry bulk protocol API constants | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 169 | skipping to change at line 169 | |||
#define SB_ATTR_INITIAL_UNKNOWN 0x01 | #define SB_ATTR_INITIAL_UNKNOWN 0x01 | |||
#define SB_OBJECT_PROFILE 0x08 | #define SB_OBJECT_PROFILE 0x08 | |||
#define SB_ATTR_PROFILE_DESC 0x02 | #define SB_ATTR_PROFILE_DESC 0x02 | |||
#define SB_ATTR_PROFILE_PIN 0x04 | #define SB_ATTR_PROFILE_PIN 0x04 | |||
#define SB_OBJECT_SOCKET_UNKNOWN 0x04 | #define SB_OBJECT_SOCKET_UNKNOWN 0x04 | |||
// param command parameters | // param command parameters | |||
//#define SB_PARAM_DEFAULT 0xff | //#define SB_PARAM_DEFAULT 0xff | |||
// DB Operation Command | // DB Operation Command | |||
#define SB_DBOP_SET_RECORD 0x41 | #define SB_DBOP_ADD_RECORD 0x41 | |||
#define SB_DBOP_CLEAR_DATABASE 0x43 | #define SB_DBOP_CLEAR_DATABASE 0x43 | |||
#define SB_DBOP_GET_DBDB 0x4a | #define SB_DBOP_GET_DBDB 0x4a | |||
#define SB_DBOP_OLD_GET_DBDB 0x4c | #define SB_DBOP_OLD_GET_DBDB 0x4c | |||
#define SB_DBOP_GET_COUNT 0x4e | #define SB_DBOP_GET_COUNT 0x4e | |||
#define SB_DBOP_GET_RECORDS 0x4f | #define SB_DBOP_GET_RECORDS 0x4f | |||
#define SB_DBOP_OLD_GET_RECORDS 0x42 | #define SB_DBOP_OLD_GET_RECORDS 0x42 | |||
#define SB_DBOP_OLD_GET_RECORDS_REPLY 0x44 | #define SB_DBOP_OLD_GET_RECORDS_REPLY 0x44 | |||
#define SB_DBOP_GET_RECORD_STATE_TABLE 0x53 // replies with 0x60, 0x41 | #define SB_DBOP_GET_RECORD_STATE_TABLE 0x53 // replies with 0x60, 0x41 | |||
#define SB_DBOP_SET_RECORD_FLAGS 0x54 // replies with 0x41 | #define SB_DBOP_SET_RECORD_FLAGS 0x54 // replies with 0x41 | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added | |||
r_bookmark.h | r_bookmark.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_bookmark.h | /// \file r_bookmark.h | |||
/// Record parsing class for call logs | /// Record parsing class for call logs | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2009, Nicolas VIVIEN | Copyright (C) 2008-2009, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 92 | skipping to change at line 92 | |||
const unsigned char* ParseStruct1Field(const unsigned char *begin, | const unsigned char* ParseStruct1Field(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
const unsigned char* ParseStruct2(const unsigned char *begin, | const unsigned char* ParseStruct2(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
public: | public: | |||
Bookmark(); | Bookmark(); | |||
~Bookmark(); | ~Bookmark(); | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void Validate() const; | ||||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
skipping to change at line 114 | skipping to change at line 115 | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
// Sorting - use enough data to make the sorting as | // Sorting - use enough data to make the sorting as | |||
// consistent as possible | // consistent as possible | |||
bool operator<(const Bookmark &other) const; | bool operator<(const Bookmark &other) const; | |||
// database name | // database name | |||
static const char * GetDBName() { return "Browser Bookmarks"; } | static const char * GetDBName() { return "Browser Bookmarks"; } | |||
static uint8_t GetDefaultRecType() { return 1; } | static uint8_t GetDefaultRecType() { return 1; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<Bookmark>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Bookmark & msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Bookmark & msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 5 lines changed or added | |||
r_calendar.h | r_calendar.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_calendar.h | /// \file r_calendar.h | |||
/// Blackberry database record parser class for calendar records . | /// Blackberry database record parser class for calendar records . | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 60 | skipping to change at line 60 | |||
typedef Barry::UnknownsType UnknownsType; | typedef Barry::UnknownsType UnknownsType; | |||
uint8_t RecType; | uint8_t RecType; | |||
uint32_t RecordId; | uint32_t RecordId; | |||
// general data | // general data | |||
bool AllDayEvent; | bool AllDayEvent; | |||
std::string Subject; | std::string Subject; | |||
std::string Notes; | std::string Notes; | |||
std::string Location; | std::string Location; | |||
time_t NotificationTime; // 0 means notification is off | Barry::TimeT NotificationTime; // 0 means notification is off | |||
time_t StartTime; | Barry::TimeT StartTime; | |||
time_t EndTime; | Barry::TimeT EndTime; | |||
EmailAddressList Organizer; | EmailAddressList Organizer; | |||
EmailAddressList AcceptedBy; | EmailAddressList AcceptedBy; | |||
EmailAddressList Invited; // list of invited people (e mail a | EmailAddressList Invited; // list of invited people (e mail a | |||
/// | /// | |||
/// Free Busy Flag | /// Free Busy Flag | |||
/// | /// | |||
/// This lists the available settings found in the device. | /// This lists the available settings found in the device. | |||
/// This list is based on information from MS Outlook 2007 | /// This list is based on information from MS Outlook 2007 | |||
/// (Free ==0 and Busy == 2) | /// (Free ==0 and Busy == 2) | |||
skipping to change at line 102 | skipping to change at line 102 | |||
enum ClassFlagType { | enum ClassFlagType { | |||
Public = 0, | Public = 0, | |||
Confidential, | Confidential, | |||
Private | Private | |||
}; | }; | |||
ClassFlagType ClassFlag; | ClassFlagType ClassFlag; | |||
uint64_t CalendarID; // Calendar ID (usefull if devices have seve ral calendars) | uint64_t CalendarID; // Calendar ID (usefull if devices have seve ral calendars) | |||
unsigned short TimeZoneCode; // the time zone originally used | uint16_t TimeZoneCode; // the time zone originally used | |||
// for the recurrence data... | // for the recurrence data... | |||
// seems to have little use, but | // seems to have little use, but | |||
// set to your current time zone | // set to your current time zone | |||
// as a good default | // as a good default | |||
bool TimeZoneValid; // true if the record contained a | bool TimeZoneValid; // true if the record contained a | |||
// time zone code | // time zone code, or in other words | |||
, | ||||
// true if TimeZoneCode contains | ||||
// valid data. Be sure to set this | ||||
to | ||||
// to true if you desire to write a | ||||
// calendar item with a time zone | ||||
// to the device, otherwise, the bui | ||||
lder | ||||
// code will skip the time zone. | ||||
// unknown | // unknown | |||
UnknownsType Unknowns; | UnknownsType Unknowns; | |||
protected: | protected: | |||
static FreeBusyFlagType FreeBusyFlagProto2Rec(uint8_t f); | static FreeBusyFlagType FreeBusyFlagProto2Rec(uint8_t f); | |||
static uint8_t FreeBusyFlagRec2Proto(FreeBusyFlagType f); | static uint8_t FreeBusyFlagRec2Proto(FreeBusyFlagType f); | |||
static ClassFlagType ClassFlagProto2Rec(uint8_t f); | static ClassFlagType ClassFlagProto2Rec(uint8_t f); | |||
static uint8_t ClassFlagRec2Proto(ClassFlagType f); | static uint8_t ClassFlagRec2Proto(ClassFlagType f); | |||
skipping to change at line 131 | skipping to change at line 137 | |||
public: | public: | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
public: | public: | |||
Calendar(); | Calendar(); | |||
~Calendar(); | ~Calendar(); | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void Validate() const; | ||||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
// operations (common among record classes) | // operations (common among record classes) | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
// sorting | // sorting | |||
bool operator<(const Calendar &other) const; | bool operator<(const Calendar &other) const; | |||
// database name | // database name | |||
static const char * GetDBName() { return "Calendar"; } | static const char * GetDBName() { return "Calendar"; } | |||
static uint8_t GetDefaultRecType() { return 5; } // or 0? | static uint8_t GetDefaultRecType() { return 5; } // or 0? | |||
// Generic Field Handle support | ||||
static const FieldHandle<Calendar>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Calendar & msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Calendar & msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
class BXEXPORT CalendarAll : public Calendar | class BXEXPORT CalendarAll : public Calendar | |||
{ | { | |||
protected: | ||||
virtual void DumpSpecialFields(std::ostream &os) const; | ||||
public: | public: | |||
std::string MailAccount; | std::string MailAccount; | |||
protected: | ||||
virtual void DumpSpecialFields(std::ostream &os) const; | ||||
public: | public: | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void Clear(); | void Clear(); | |||
public: | public: | |||
// database name | // database name | |||
static const char * GetDBName() { return "Calendar - All"; } | static const char * GetDBName() { return "Calendar - All"; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<CalendarAll>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CalendarAl l &msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CalendarAl l &msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
End of changes. 9 change blocks. | ||||
9 lines changed or deleted | 25 lines changed or added | |||
r_calllog.h | r_calllog.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_calllog.h | /// \file r_calllog.h | |||
/// Record parsing class for call logs | /// Record parsing class for call logs | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2009, Nicolas VIVIEN | Copyright (C) 2008-2009, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 110 | skipping to change at line 110 | |||
static uint8_t DirectionRec2Proto(DirectionFlagType s); | static uint8_t DirectionRec2Proto(DirectionFlagType s); | |||
static PhoneTypeFlagType PhoneTypeProto2Rec(uint8_t s); | static PhoneTypeFlagType PhoneTypeProto2Rec(uint8_t s); | |||
static uint8_t PhoneTypeRec2Proto(PhoneTypeFlagType s); | static uint8_t PhoneTypeRec2Proto(PhoneTypeFlagType s); | |||
public: | public: | |||
CallLog(); | CallLog(); | |||
~CallLog(); | ~CallLog(); | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void Validate() const; | ||||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
skipping to change at line 131 | skipping to change at line 132 | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
// Sorting | // Sorting | |||
bool operator<(const CallLog &other) const { return Timestamp < othe r.Timestamp; } | bool operator<(const CallLog &other) const { return Timestamp < othe r.Timestamp; } | |||
// database name | // database name | |||
static const char * GetDBName() { return "Phone Call Logs"; } | static const char * GetDBName() { return "Phone Call Logs"; } | |||
static uint8_t GetDefaultRecType() { return 0; } | static uint8_t GetDefaultRecType() { return 0; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<CallLog>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CallLog &m sg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CallLog &m sg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 5 lines changed or added | |||
r_contact.h | r_contact.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_contact.h | /// \file r_contact.h | |||
/// Blackberry database record parser class for contact records. | /// Blackberry database record parser class for contact records. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 69 | skipping to change at line 69 | |||
// | // | |||
/// Represents a single record in the Address Book Blackberry database. | /// Represents a single record in the Address Book Blackberry database. | |||
/// | /// | |||
class BXEXPORT Contact | class BXEXPORT Contact | |||
{ | { | |||
public: | public: | |||
typedef Barry::CategoryList CategoryList; | typedef Barry::CategoryList CategoryList; | |||
typedef ContactGroupLink GroupLink; | typedef ContactGroupLink GroupLink; | |||
typedef std::vector<GroupLink> GroupLinksType; | typedef std::vector<GroupLink> GroupLinksType; | |||
typedef Barry::UnknownsType UnknownsType; | typedef Barry::UnknownsType UnknownsType; | |||
typedef std::string EmailType; | typedef Barry::EmailType EmailType; | |||
typedef std::vector<EmailType> EmailList; | typedef Barry::EmailList EmailList; | |||
// | // | |||
// Record fields | // Record fields | |||
// | // | |||
// contact specific data | // contact specific data | |||
uint8_t RecType; | uint8_t RecType; | |||
uint32_t RecordId; | uint32_t RecordId; | |||
EmailList EmailAddresses; | EmailList EmailAddresses; | |||
skipping to change at line 150 | skipping to change at line 150 | |||
public: | public: | |||
Contact(); | Contact(); | |||
~Contact(); | ~Contact(); | |||
uint32_t GetID() const { return RecordId; } | uint32_t GetID() const { return RecordId; } | |||
std::string GetFullName() const; | std::string GetFullName() const; | |||
const std::string& GetEmail(unsigned int index = 0) const; | const std::string& GetEmail(unsigned int index = 0) const; | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void Validate() const; | ||||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
// operations (common among record classes) | // operations (common among record classes) | |||
void Clear(); // erase everything | void Clear(); // erase everything | |||
skipping to change at line 173 | skipping to change at line 174 | |||
// Sorting - use enough data to make the sorting as | // Sorting - use enough data to make the sorting as | |||
// consistent as possible | // consistent as possible | |||
bool operator<(const Contact &other) const; | bool operator<(const Contact &other) const; | |||
// database name | // database name | |||
static const char * GetDBName() { return "Address Book"; } | static const char * GetDBName() { return "Address Book"; } | |||
static uint8_t GetDefaultRecType() { return 0; } | static uint8_t GetDefaultRecType() { return 0; } | |||
// helpers | // helpers | |||
static void SplitName(const std::string &full, std::string &first, s td::string &last); | static void SplitName(const std::string &full, std::string &first, s td::string &last); | |||
static std::string Email2CommaString(const EmailList &list); | ||||
static void CommaString2Email(const std::string &list, EmailList &re | ||||
sult); | ||||
// Generic Field Handle support | ||||
static const FieldHandle<Contact>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<< (std::ostream &os, const Contact & contact) { | BXEXPORT inline std::ostream& operator<< (std::ostream &os, const Contact & contact) { | |||
contact.Dump(os); | contact.Dump(os); | |||
return os; | return os; | |||
} | } | |||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
End of changes. 4 change blocks. | ||||
3 lines changed or deleted | 10 lines changed or added | |||
r_cstore.h | r_cstore.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_cstore.h | /// \file r_cstore.h | |||
/// Blackberry database record parser class for | /// Blackberry database record parser class for | |||
/// Content Store records. | /// Content Store records. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 93 | skipping to change at line 93 | |||
// operations (common among record classes) | // operations (common among record classes) | |||
void Clear(); // erase everything | void Clear(); // erase everything | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
// Sorting - use enough data to make the sorting as | // Sorting - use enough data to make the sorting as | |||
// consistent as possible | // consistent as possible | |||
bool operator<(const ContentStore &other) const; | bool operator<(const ContentStore &other) const; | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void Validate() const; | ||||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
static const char * GetDBName() { return "Content Store"; } | static const char * GetDBName() { return "Content Store"; } | |||
static uint8_t GetDefaultRecType() { return 0; } | static uint8_t GetDefaultRecType() { return 0; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<ContentStore>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<< (std::ostream &os, | BXEXPORT inline std::ostream& operator<< (std::ostream &os, | |||
const ContentStore &cstore) | const ContentStore &cstore) | |||
{ | { | |||
cstore.Dump(os); | cstore.Dump(os); | |||
return os; | return os; | |||
} | } | |||
/// @} | /// @} | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 5 lines changed or added | |||
r_folder.h | r_folder.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_folder.h | /// \file r_folder.h | |||
/// Record parsing class for the Folder database. | /// Record parsing class for the Folder database. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2007, Brian Edginton | Copyright (C) 2007, Brian Edginton | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 76 | skipping to change at line 76 | |||
UnknownsType Unknowns; | UnknownsType Unknowns; | |||
protected: | protected: | |||
static FolderType TypeProto2Rec(uint8_t t); | static FolderType TypeProto2Rec(uint8_t t); | |||
static uint8_t TypeRec2Proto(FolderType t); | static uint8_t TypeRec2Proto(FolderType t); | |||
public: | public: | |||
Folder(); | Folder(); | |||
~Folder(); | ~Folder(); | |||
// Parser / Builder API (see parser.h / builder.h) | ||||
void Validate() const; | ||||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
skipping to change at line 97 | skipping to change at line 99 | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
bool operator<(const Folder &other) const { return Name < other.Name ; } | bool operator<(const Folder &other) const { return Name < other.Name ; } | |||
// database name | // database name | |||
static const char * GetDBName() { return "Folders"; } | static const char * GetDBName() { return "Folders"; } | |||
static uint8_t GetDefaultRecType() { return 0; } | static uint8_t GetDefaultRecType() { return 0; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<Folder>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Folder &ms g) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Folder &ms g) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
} // namespace Barry | } // namespace Barry | |||
#endif // __BARRY_RECORD_FOLDER_H__ | #endif // __BARRY_RECORD_FOLDER_H__ | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 5 lines changed or added | |||
r_memo.h | r_memo.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_memo.h | /// \file r_memo.h | |||
/// Record parsing class for the memo database. | /// Record parsing class for the memo database. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2007, Brian Edginton | Copyright (C) 2007, Brian Edginton | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 60 | skipping to change at line 60 | |||
public: | public: | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
public: | public: | |||
Memo(); | Memo(); | |||
~Memo(); | ~Memo(); | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void Validate() const; | ||||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
// operations (common among record classes) | // operations (common among record classes) | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
bool operator<(const Memo &other) const; | bool operator<(const Memo &other) const; | |||
// database name | // database name | |||
static const char * GetDBName() { return "Memos"; } | static const char * GetDBName() { return "Memos"; } | |||
static uint8_t GetDefaultRecType() { return 0; } // or 0? | static uint8_t GetDefaultRecType() { return 0; } // or 0? | |||
// Generic Field Handle support | ||||
static const FieldHandle<Memo>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Memo &msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Memo &msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 5 lines changed or added | |||
r_message.h | r_message.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_message.h | /// \file r_message.h | |||
/// Blackberry database record parser class for email records. | /// Blackberry database record parser class for email records. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 41 | skipping to change at line 41 | |||
// NOTE: All classes here must be container-safe! Perhaps add sorting | // NOTE: All classes here must be container-safe! Perhaps add sorting | |||
// operators in the future. | // operators in the future. | |||
// | // | |||
/// \addtogroup RecordParserClasses | /// \addtogroup RecordParserClasses | |||
/// @{ | /// @{ | |||
class BXEXPORT Message : public MessageBase | class BXEXPORT Message : public MessageBase | |||
{ | { | |||
public: | public: | |||
Message() | ||||
{ | ||||
// must call this again, since base class can't call ours | ||||
Clear(); | ||||
} | ||||
void Clear() | void Clear() | |||
{ | { | |||
MessageBase::Clear(); | MessageBase::Clear(); | |||
RecType = GetDefaultRecType(); | RecType = GetDefaultRecType(); | |||
RecordId = 0; | RecordId = 0; | |||
} | } | |||
// database name | // database name | |||
static const char * GetDBName() { return "Messages"; } | static const char * GetDBName() { return "Messages"; } | |||
static uint8_t GetDefaultRecType() { return 0; } | static uint8_t GetDefaultRecType() { return 0; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<Message>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Message &m sg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Message &m sg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 10 lines changed or added | |||
r_message_base.h | r_message_base.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_message_base.h | /// \file r_message_base.h | |||
/// Base class for email-oriented Blackberry database records | /// Base class for email-oriented Blackberry database records | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2007, Brian Edginton (edge@edginton.net) | Copyright (C) 2007, Brian Edginton (edge@edginton.net) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 70 | skipping to change at line 70 | |||
std::string Attachment; //< not available for PINMes sage? | std::string Attachment; //< not available for PINMes sage? | |||
uint32_t MessageRecordId; // in PINMessage, this happens to be | uint32_t MessageRecordId; // in PINMessage, this happens to be | |||
// the same as RecordId in my (CDF) | // the same as RecordId in my (CDF) | |||
// testing, but interestingly, it is | // testing, but interestingly, it is | |||
// stored as a field *inside* the | // stored as a field *inside* the | |||
// record, and not as part of the | // record, and not as part of the | |||
// header... in effect, this record ID | // header... in effect, this record ID | |||
// occurs twice in the protocol | // occurs twice in the protocol | |||
uint32_t MessageReplyTo; | uint32_t MessageReplyTo; | |||
time_t MessageDateSent; | Barry::TimeT MessageDateSent; | |||
time_t MessageDateReceived; | Barry::TimeT MessageDateReceived; | |||
// Message Flags | // Message Flags | |||
bool MessageTruncated; | bool MessageTruncated; | |||
bool MessageRead; | bool MessageRead; | |||
bool MessageReply; | bool MessageReply; | |||
bool MessageSaved; | bool MessageSaved; | |||
bool MessageSavedDeleted; | bool MessageSavedDeleted; | |||
enum PriorityType { | enum PriorityType { | |||
LowPriority = 0, | LowPriority = 0, | |||
skipping to change at line 112 | skipping to change at line 112 | |||
public: | public: | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
protected: | protected: | |||
MessageBase(); | MessageBase(); | |||
~MessageBase(); | ~MessageBase(); | |||
public: | public: | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
uint8_t GetRecType() const; | void Validate() const; | |||
uint32_t GetUniqueId() const; // empty API, not required by protoc | uint8_t GetRecType() const { return RecType; } | |||
ol | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id){ RecType = Type; RecordId = I d; } | void SetIds(uint8_t Type, uint32_t Id){ RecType = Type; RecordId = I d; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
// operations (common among record classes) | // operations (common among record classes) | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
End of changes. 3 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added | |||
r_pin_message.h | r_pin_message.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_pin_message.h | /// \file r_pin_message.h | |||
/// Blackberry database record parser class for pin message reco rds. | /// Blackberry database record parser class for pin message reco rds. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2007, Brian Edginton (edge@edginton.net) | Copyright (C) 2007, Brian Edginton (edge@edginton.net) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 42 | skipping to change at line 42 | |||
// NOTE: All classes here must be container-safe! Perhaps add sorting | // NOTE: All classes here must be container-safe! Perhaps add sorting | |||
// operators in the future. | // operators in the future. | |||
// | // | |||
/// \addtogroup RecordParserClasses | /// \addtogroup RecordParserClasses | |||
/// @{ | /// @{ | |||
class BXEXPORT PINMessage : public MessageBase | class BXEXPORT PINMessage : public MessageBase | |||
{ | { | |||
public: | public: | |||
PINMessage() | ||||
{ | ||||
// must call this again, since base class can't call ours | ||||
Clear(); | ||||
} | ||||
void Clear() | void Clear() | |||
{ | { | |||
MessageBase::Clear(); | MessageBase::Clear(); | |||
RecType = GetDefaultRecType(); | RecType = GetDefaultRecType(); | |||
RecordId = 0; | RecordId = 0; | |||
} | } | |||
// database name | // database name | |||
static const char * GetDBName() { return "PIN Messages"; } | static const char * GetDBName() { return "PIN Messages"; } | |||
static uint8_t GetDefaultRecType() { return 0; } | static uint8_t GetDefaultRecType() { return 0; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<PINMessage>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const PINMessage &msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const PINMessage &msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 10 lines changed or added | |||
r_recur_base.h | r_recur_base.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_recur_base.h | /// \file r_recur_base.h | |||
/// Base class for recurring calendar event data. | /// Base class for recurring calendar event data. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 70 | skipping to change at line 70 | |||
//< set: DayOfMonth and MonthOfYear | //< set: DayOfMonth and MonthOfYear | |||
YearByDay = 6, //< eg. every year on 3rd Wed of Jan | YearByDay = 6, //< eg. every year on 3rd Wed of Jan | |||
//< set: DayOfWeek, WeekOfMonth, and | //< set: DayOfWeek, WeekOfMonth, and | |||
//< MonthOfYear | //< MonthOfYear | |||
Week = 12 //< eg. every week on Mon and Fri | Week = 12 //< eg. every week on Mon and Fri | |||
//< set: WeekDays | //< set: WeekDays | |||
}; | }; | |||
bool Recurring; | bool Recurring; | |||
RecurringCodeType RecurringType; | RecurringCodeType RecurringType; | |||
unsigned short Interval; // must be >= 1 | uint16_t Interval; // must be >= 1 | |||
time_t RecurringEndTime; // only pertains if Recurring is tru | Barry::TimeT RecurringEndTime; // only pertains if Recurring is tru | |||
e | e | |||
// sets the date and time when | // sets the date and time when | |||
// recurrence of this appointment | // recurrence of this appointment | |||
// should no longer occur | // should no longer occur | |||
// If a perpetual appointment, this | // If a perpetual appointment, this | |||
// is 0xFFFFFFFF in the low level da ta | // is 0xFFFFFFFF in the low level da ta | |||
// Instead, set the following flag. | // Instead, set the following flag. | |||
bool Perpetual; // if true, this will always recur | bool Perpetual; // if true, this will always recur | |||
unsigned short // recurring details, depending on t ype | uint16_t // recurring details, depending on t ype | |||
DayOfWeek, // 0-6 | DayOfWeek, // 0-6 | |||
WeekOfMonth, // 1-5 | WeekOfMonth, // 1-5 | |||
DayOfMonth, // 1-31 | DayOfMonth, // 1-31 | |||
MonthOfYear; // 1-12 | MonthOfYear; // 1-12 | |||
unsigned char WeekDays; // bitmask, bit 0 = sunday | uint8_t WeekDays; // bitmask, bit 0 = sunday | |||
// FIXME - put these somewhere usable by both C and C++ | // FIXME - put these somewhere usable by both C and C++ | |||
#define CAL_WD_SUN 0x01 | #define CAL_WD_SUN 0x01 | |||
#define CAL_WD_MON 0x02 | #define CAL_WD_MON 0x02 | |||
#define CAL_WD_TUE 0x04 | #define CAL_WD_TUE 0x04 | |||
#define CAL_WD_WED 0x08 | #define CAL_WD_WED 0x08 | |||
#define CAL_WD_THU 0x10 | #define CAL_WD_THU 0x10 | |||
#define CAL_WD_FRI 0x20 | #define CAL_WD_FRI 0x20 | |||
#define CAL_WD_SAT 0x40 | #define CAL_WD_SAT 0x40 | |||
protected: | protected: | |||
void ParseRecurrenceData(const void *data); | void ParseRecurrenceData(const void *data); | |||
static unsigned char WeekDayProto2Rec(uint8_t raw_field); | static unsigned char WeekDayProto2Rec(uint8_t raw_field); | |||
static uint8_t WeekDayRec2Proto(unsigned char weekdays); | static uint8_t WeekDayRec2Proto(unsigned char weekdays); | |||
protected: | protected: | |||
RecurBase(); | RecurBase(); | |||
virtual ~RecurBase(); | virtual ~RecurBase(); | |||
public: | public: | |||
void Validate() const; | ||||
// return true if parse, false if not (for example, if type not | // return true if parse, false if not (for example, if type not | |||
// recognized) | // recognized) | |||
bool ParseField(uint8_t type, const unsigned char *data, size_t size , | bool ParseField(uint8_t type, const unsigned char *data, size_t size , | |||
const IConverter *ic = 0); | const IConverter *ic = 0); | |||
void BuildRecurrenceData(time_t StartTime, void *data) const; | void BuildRecurrenceData(time_t StartTime, void *data) const; | |||
uint8_t RecurringFieldType() const; | uint8_t RecurringFieldType() const; | |||
void Clear(); | void Clear(); | |||
End of changes. 5 change blocks. | ||||
6 lines changed or deleted | 8 lines changed or added | |||
r_saved_message.h | r_saved_message.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_save_message.h | /// \file r_saved_message.h | |||
/// Blackberry database record parser class for saved email | /// Blackberry database record parser class for saved email | |||
/// message records. | /// message records. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2007, Brian Edginton (edge@edginton.net) | Copyright (C) 2007, Brian Edginton (edge@edginton.net) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 43 | skipping to change at line 43 | |||
// NOTE: All classes here must be container-safe! Perhaps add sorting | // NOTE: All classes here must be container-safe! Perhaps add sorting | |||
// operators in the future. | // operators in the future. | |||
// | // | |||
/// \addtogroup RecordParserClasses | /// \addtogroup RecordParserClasses | |||
/// @{ | /// @{ | |||
class BXEXPORT SavedMessage : public MessageBase | class BXEXPORT SavedMessage : public MessageBase | |||
{ | { | |||
public: | public: | |||
SavedMessage() | ||||
{ | ||||
Clear(); | ||||
} | ||||
void Clear() | void Clear() | |||
{ | { | |||
MessageBase::Clear(); | MessageBase::Clear(); | |||
RecType = GetDefaultRecType(); | RecType = GetDefaultRecType(); | |||
RecordId = 0; | RecordId = 0; | |||
} | } | |||
// database name | // database name | |||
static const char * GetDBName() { return "Saved Email Messages"; } | static const char * GetDBName() { return "Saved Email Messages"; } | |||
static uint8_t GetDefaultRecType() { return 3; } | static uint8_t GetDefaultRecType() { return 3; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<SavedMessage>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const SavedMessa ge &msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const SavedMessa ge &msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 10 lines changed or added | |||
r_servicebook.h | r_servicebook.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_servicebook.h | /// \file r_servicebook.h | |||
/// Blackberry database record parser class for the | /// Blackberry database record parser class for the | |||
/// Service Book record. | /// Service Book record. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 67 | skipping to change at line 67 | |||
public: | public: | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
public: | public: | |||
ServiceBookConfig(); | ServiceBookConfig(); | |||
~ServiceBookConfig(); | ~ServiceBookConfig(); | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void Validate() const; | ||||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
}; | }; | |||
skipping to change at line 113 | skipping to change at line 114 | |||
public: | public: | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
public: | public: | |||
ServiceBook(); | ServiceBook(); | |||
~ServiceBook(); | ~ServiceBook(); | |||
// Parser / Builder API (see parser.h / builder.h) | // Parser / Builder API (see parser.h / builder.h) | |||
void Validate() const; | ||||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
// operations (common among record classes) | // operations (common among record classes) | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
// sorting | // sorting | |||
bool operator<(const ServiceBook &other) const; | bool operator<(const ServiceBook &other) const; | |||
// database name | // database name | |||
static const char * GetDBName() { return "Service Book"; } | static const char * GetDBName() { return "Service Book"; } | |||
static uint8_t GetDefaultRecType() { return 0; } | static uint8_t GetDefaultRecType() { return 0; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<ServiceBook>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBoo k &msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBoo k &msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
End of changes. 4 change blocks. | ||||
1 lines changed or deleted | 6 lines changed or added | |||
r_sms.h | r_sms.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_task.h | /// \file r_sms.h | |||
/// Record parsing class for the task database. | /// Record parsing class for SMS messages. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2009, Ryan Li(ryan@ryanium.com) | Copyright (C) 2009, Ryan Li(ryan@ryanium.com) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 58 | skipping to change at line 58 | |||
Received, | Received, | |||
Sent, | Sent, | |||
Draft | Draft | |||
}; | }; | |||
MessageType MessageStatus; | MessageType MessageStatus; | |||
enum DeliveryType | enum DeliveryType | |||
{ | { | |||
NoReport = 0, | NoReport = 0, | |||
Failed, | Failed, | |||
Succedded | Succeeded | |||
}; | }; | |||
DeliveryType DeliveryStatus; // not implemented yet | DeliveryType DeliveryStatus; // not implemented yet | |||
bool IsNew; | bool IsNew; | |||
bool NewConversation; | bool NewConversation; | |||
bool Saved; | bool Saved; | |||
bool Deleted; | bool Deleted; | |||
bool Opened; | bool Opened; | |||
uint64_t Timestamp; // milliseconds from Jan 1, 1970 | uint64_t Timestamp; // milliseconds from Jan 1, 1970 | |||
skipping to change at line 81 | skipping to change at line 81 | |||
enum DataCodingSchemeType | enum DataCodingSchemeType | |||
{ | { | |||
SevenBit = 0, | SevenBit = 0, | |||
EightBit, | EightBit, | |||
UCS2 | UCS2 | |||
}; | }; | |||
DataCodingSchemeType DataCodingScheme; | DataCodingSchemeType DataCodingScheme; | |||
uint32_t ErrorId; | uint32_t ErrorId; | |||
std::vector<std::string> Addresses; | EmailList Addresses; //< not strictly email, but just a l | |||
ist | ||||
//< strings, used for phone numbers | ||||
std::string Body; | std::string Body; | |||
UnknownsType Unknowns; | UnknownsType Unknowns; | |||
public: | public: | |||
Sms(); | Sms(); | |||
~Sms(); | ~Sms(); | |||
time_t GetTime() const; | time_t GetTime() const; | |||
time_t GetServiceCenterTime() const; | time_t GetServiceCenterTime() const; | |||
void SetTime(const time_t timestamp, unsigned int milliseconds = 0); | void SetTime(const time_t timestamp, unsigned int milliseconds = 0); | |||
void SetServiceCenterTime(const time_t timestamp, unsigned int milli seconds = 0); | void SetServiceCenterTime(const time_t timestamp, unsigned int milli seconds = 0); | |||
// Parser / Builder API (see parser.h / builder.h) | ||||
void Validate() const; | ||||
const unsigned char* ParseField(const unsigned char *begin, const un signed char *end, const IConverter *ic = 0); | const unsigned char* ParseField(const unsigned char *begin, const un signed char *end, const IConverter *ic = 0); | |||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
// operations (common among record classes) | // operations (common among record classes) | |||
skipping to change at line 119 | skipping to change at line 122 | |||
static std::string ConvertGsmToUtf8(const std::string &); | static std::string ConvertGsmToUtf8(const std::string &); | |||
// sorting | // sorting | |||
bool operator<(const Sms &other) const { | bool operator<(const Sms &other) const { | |||
return Timestamp < other.Timestamp; | return Timestamp < other.Timestamp; | |||
} | } | |||
// database name | // database name | |||
static const char * GetDBName() { return "SMS Messages"; } | static const char * GetDBName() { return "SMS Messages"; } | |||
static uint8_t GetDefaultRecType() { return 5; } | static uint8_t GetDefaultRecType() { return 5; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<Sms>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Sms &msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Sms &msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 12 lines changed or added | |||
r_task.h | r_task.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_task.h | /// \file r_task.h | |||
/// Record parsing class for the task database. | /// Record parsing class for the task database. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2007, Brian Edginton | Copyright (C) 2007, Brian Edginton | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 38 | skipping to change at line 38 | |||
#include "r_recur_base.h" | #include "r_recur_base.h" | |||
#include <vector> | #include <vector> | |||
#include <string> | #include <string> | |||
#include <stdint.h> | #include <stdint.h> | |||
namespace Barry { | namespace Barry { | |||
// forward declarations | // forward declarations | |||
class IConverter; | class IConverter; | |||
// | ||||
// Task record class | ||||
// | ||||
/// Task record class. Note that there is a bug in many device firmwares. | ||||
/// | ||||
/// If you extract a Tasks record, and then write it back via | ||||
/// SetRecordByIndex(), on many devices that I tested, it ends up | ||||
/// corrupting the record on the device, and the GUI on the device | ||||
/// appears messed up. (It shows the first few fields twice) | ||||
/// Such a corrupt record also loses the due date. | ||||
/// | ||||
/// The workaround, when working with the Tasks database, is to | ||||
/// first DeleteByIndex() and then AddRecord() via the Desktop mode class, | ||||
/// using the same record ID. This works, but is unfortunately | ||||
/// cumbersome. | ||||
/// | ||||
/// See the Desktop GUI and the opensync plugins for examples of this | ||||
/// workaround. | ||||
/// | ||||
/// Ideally, we should test a Tasks sync on Windows, and see how | ||||
/// the Windows software handles this. There may be some protocol | ||||
/// changes that will be needed in future Barry versions. | ||||
/// | ||||
class BXEXPORT Task : public RecurBase | class BXEXPORT Task : public RecurBase | |||
{ | { | |||
public: | public: | |||
typedef Barry::UnknownsType UnknownsType; | typedef Barry::UnknownsType UnknownsType; | |||
uint8_t RecType; | uint8_t RecType; | |||
uint32_t RecordId; | uint32_t RecordId; | |||
std::string Summary; | std::string Summary; | |||
std::string Notes; | std::string Notes; | |||
CategoryList Categories; | CategoryList Categories; | |||
std::string UID; | std::string UID; | |||
time_t StartTime; | Barry::TimeT StartTime; // most devices set this the same as | |||
time_t DueTime; | // DueTime... this is a read-only | |||
time_t AlarmTime; | // variable. By setting DueTime, | |||
unsigned short TimeZoneCode; | // the library will write StartTime | |||
// for you automatically | ||||
Barry::TimeT DueTime; | ||||
Barry::TimeT AlarmTime; | ||||
uint16_t TimeZoneCode; | ||||
bool TimeZoneValid; // true if the record contained a | bool TimeZoneValid; // true if the record contained a | |||
// time zone code | // time zone code | |||
enum AlarmFlagType | enum AlarmFlagType | |||
{ | { | |||
Date = 1, | Date = 1, | |||
Relative | Relative | |||
}; | }; | |||
AlarmFlagType AlarmType; | AlarmFlagType AlarmType; | |||
skipping to change at line 83 | skipping to change at line 110 | |||
enum StatusFlagType | enum StatusFlagType | |||
{ | { | |||
NotStarted = 0, | NotStarted = 0, | |||
InProgress, | InProgress, | |||
Completed, | Completed, | |||
Waiting, | Waiting, | |||
Deferred | Deferred | |||
}; | }; | |||
StatusFlagType StatusFlag; | StatusFlagType StatusFlag; | |||
bool DueDateFlag; // true if due date is set | ||||
// unknown | // unknown | |||
UnknownsType Unknowns; | UnknownsType Unknowns; | |||
protected: | protected: | |||
static AlarmFlagType AlarmProto2Rec(uint8_t a); | static AlarmFlagType AlarmProto2Rec(uint8_t a); | |||
static uint8_t AlarmRec2Proto(AlarmFlagType a); | static uint8_t AlarmRec2Proto(AlarmFlagType a); | |||
static PriorityFlagType PriorityProto2Rec(uint8_t p); | static PriorityFlagType PriorityProto2Rec(uint8_t p); | |||
static uint8_t PriorityRec2Proto(PriorityFlagType p); | static uint8_t PriorityRec2Proto(PriorityFlagType p); | |||
static StatusFlagType StatusProto2Rec(uint8_t s); | static StatusFlagType StatusProto2Rec(uint8_t s); | |||
static uint8_t StatusRec2Proto(StatusFlagType s); | static uint8_t StatusRec2Proto(StatusFlagType s); | |||
public: | public: | |||
Task(); | Task(); | |||
~Task(); | ~Task(); | |||
// Parser / Builder API (see parser.h / builder.h) | ||||
void Validate() const; | ||||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
skipping to change at line 123 | skipping to change at line 150 | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
bool operator<(const Task &other) const; | bool operator<(const Task &other) const; | |||
// database name | // database name | |||
static const char * GetDBName() { return "Tasks"; } | static const char * GetDBName() { return "Tasks"; } | |||
static uint8_t GetDefaultRecType() { return 2; } | static uint8_t GetDefaultRecType() { return 2; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<Task>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Task &msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Task &msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 6 change blocks. | ||||
7 lines changed or deleted | 36 lines changed or added | |||
r_timezone.h | r_timezone.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file r_timezone.h | /// \file r_timezone.h | |||
/// Record parsing class for the timezone database. | /// Record parsing class for the timezone database. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
Copyright (C) 2008, Brian Edginton | Copyright (C) 2008, Brian Edginton | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 37 | skipping to change at line 37 | |||
#include "record.h" | #include "record.h" | |||
#include <vector> | #include <vector> | |||
#include <string> | #include <string> | |||
#include <stdint.h> | #include <stdint.h> | |||
namespace Barry { | namespace Barry { | |||
// forward declarations | // forward declarations | |||
class IConverter; | class IConverter; | |||
class BXEXPORT Timezone | class BXEXPORT TimeZone | |||
{ | { | |||
public: | public: | |||
typedef Barry::UnknownsType UnknownsType; | typedef Barry::UnknownsType UnknownsType; | |||
uint8_t RecType; | uint8_t RecType; | |||
uint32_t RecordId; | uint32_t RecordId; | |||
uint8_t TZType; | std::string Name; //< name of time zone | |||
uint32_t DSTOffset; | ||||
int32_t Index; | ||||
int32_t Offset; | ||||
int32_t OffsetFraction; | ||||
uint32_t StartMonth; | ||||
uint32_t EndMonth; | ||||
bool Left; | ||||
bool UseDST; | ||||
std::string TimeZoneName; | int32_t Index; //< index of entry in time zone tabl | |||
e... | ||||
//< matches Code in hard coded TimeZ | ||||
one | ||||
//< table in Barry | ||||
int32_t UTCOffset; //< Timezone offset from UTC in minu | ||||
tes. | ||||
//< Will be a negative value for wes | ||||
t | ||||
//< of UTC (North America, etc), and | ||||
//< a positive value for east (Europ | ||||
e). | ||||
//< i.e. -210 for St. John's, which | ||||
is | ||||
//< -3.5 hours from UTC. | ||||
bool UseDST; //< true this timezone uses DST | ||||
uint32_t DSTOffset; //< minutes of DST, if UseDST is tru | ||||
e. | ||||
//< This value will almost always be | ||||
60. | ||||
uint32_t StartMonth; //< index, 0-11, of month to start D | ||||
ST | ||||
uint32_t EndMonth; //< index, 0-11, of month to end DST | ||||
uint8_t TZType; //< unknown | ||||
UnknownsType Unknowns; | UnknownsType Unknowns; | |||
public: | public: | |||
TimeZone(); | ||||
Timezone(); | /// Creates a new timezone based on utc_offset minutes. | |||
virtual ~Timezone(); | /// Use same semantics as UTCOffset. For example, a -3.5 hour | |||
/// timezone (which is west of UTC) would be constructed | ||||
/// as: TimeZone(-210) | ||||
explicit TimeZone(int utc_offset); | ||||
/// Creates a new timezone based on negative/positive hours, | ||||
/// and positive minutes. For example, a -3.5 hour timezone | ||||
/// (which is west of UTC) would be constructed as: TimeZone(-3, 30) | ||||
/// Note that minutes can be negative, and it will be handled | ||||
/// correctly. i.e. TimeZone(-3, 30) == TimeZone(-3, -30) | ||||
TimeZone(int hours, int minutes); | ||||
virtual ~TimeZone(); | ||||
// | ||||
// TimeZone related utility functions | ||||
// | ||||
bool IsWest() const { return UTCOffset < 0; } | ||||
/// Splits UTCOffset minutes into hours and minutes. hours can be | ||||
/// negative. minutes is always positive. | ||||
void Split(int *hours, int *minutes) const; | ||||
/// Splits UTCOffset minutes into absolute values of hours and minut | ||||
es, | ||||
/// and sets the west flag appropriately. This is to mimic the | ||||
/// old behaviour of the Left, Offset and OffsetFraction member | ||||
/// variables. | ||||
void SplitAbsolute(bool *west, | ||||
unsigned int *hours, unsigned int *minutes) const; | ||||
/// Creates a timezone string suitable for a Unix / POSIX TZ | ||||
/// environment variable. Expects a time zone prefix. | ||||
/// For example, New Zealand Standard/Daylight Time is NZST/NZDT, so | ||||
/// the prefix would be "NZ". Eastern Standard/Daylight Time | ||||
/// is EST/EDT, so the prefix would be "E". | ||||
/// | ||||
/// Should be able to use this string to achieve time zone conversio | ||||
ns | ||||
/// using the TzWrapper class. | ||||
std::string GetTz(const std::string &prefix) const; | ||||
// common Barry record functions | ||||
void Validate() const; | ||||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end, const IConverter *ic = 0); | const unsigned char *end, const IConverter *ic = 0); | |||
void ParseRecurrenceData(const void *data); | void ParseRecurrenceData(const void *data); | |||
void BuildRecurrenceData(void *data); | void BuildRecurrenceData(void *data); | |||
uint8_t GetRecType() const { return RecType; } | uint8_t GetRecType() const { return RecType; } | |||
uint32_t GetUniqueId() const { return RecordId; } | uint32_t GetUniqueId() const { return RecordId; } | |||
void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; } | |||
void ParseHeader(const Data &data, size_t &offset); | void ParseHeader(const Data &data, size_t &offset); | |||
void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0); | |||
void BuildHeader(Data &data, size_t &offset) const; | void BuildHeader(Data &data, size_t &offset) const; | |||
void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const; | |||
// operations (common among record classes) | // operations (common among record classes) | |||
void Clear(); | void Clear(); | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
std::string GetDescription() const; | std::string GetDescription() const; | |||
bool operator<(const Timezone &other) const { return TimeZoneName < | bool operator<(const TimeZone &other) const { return SortByName(*thi | |||
other.TimeZoneName; } | s, other); } | |||
// sort options - suitable for use in std::sort() | ||||
static bool SortByName(const TimeZone &a, const TimeZone &b) | ||||
{ | ||||
return a.Name < b.Name; | ||||
} | ||||
static bool SortByZone(const TimeZone &a, const TimeZone &b) | ||||
{ | ||||
return a.UTCOffset < b.UTCOffset; | ||||
} | ||||
// database name | // database name | |||
static const char * GetDBName() { return "Time Zones"; } | static const char * GetDBName() { return "Time Zones"; } | |||
static uint8_t GetDefaultRecType() { return 2; } | static uint8_t GetDefaultRecType() { return 2; } | |||
// Generic Field Handle support | ||||
static const FieldHandle<TimeZone>::ListT& GetFieldHandles(); | ||||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Timezone & msg) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const TimeZone & msg) { | |||
msg.Dump(os); | msg.Dump(os); | |||
return os; | return os; | |||
} | } | |||
// forward declarations | ||||
namespace Mode { | ||||
class Desktop; | ||||
} | ||||
// | ||||
// TimeZones | ||||
// | ||||
/// Creates a vector of TimeZone objects either based on the library's | ||||
/// hard coded StaticTimeZone list, or by extracting the time zone database | ||||
/// from a given device. | ||||
/// | ||||
/// After construction, the vector will be sorted according to time zone, | ||||
/// with west-most first. | ||||
/// | ||||
class BXEXPORT TimeZones | ||||
{ | ||||
public: | ||||
typedef std::vector<TimeZone> ListType; | ||||
typedef ListType::iterator iterator; | ||||
typedef ListType::const_iterator const_iterator; | ||||
private: | ||||
ListType m_list; | ||||
public: | ||||
/// Creates the list based on the library's hard coded StaticTimeZon | ||||
e | ||||
/// list. | ||||
TimeZones(); | ||||
/// Extracts the time zone database from the given device. | ||||
/// Throws an exception if the device does not have a time zones | ||||
/// database. | ||||
explicit TimeZones(Barry::Mode::Desktop &desktop); | ||||
/// Static helper function that returns true if the device | ||||
/// referenced by desktop has a time zone database | ||||
static bool IsLoadable(Barry::Mode::Desktop &desktop); | ||||
ListType& GetList() { return m_list; } | ||||
const ListType& GetList() const { return m_list; } | ||||
iterator begin() { return m_list.begin(); } | ||||
const_iterator begin() const { return m_list.begin(); } | ||||
iterator end() { return m_list.end(); } | ||||
const_iterator end() const { return m_list.end(); } | ||||
TimeZone& operator[](int i) { return m_list[i]; } | ||||
const TimeZone& operator[](int i) const { return m_list[i]; } | ||||
// utility functions - return end() if not found | ||||
iterator Find(int index); | ||||
const_iterator Find(int index) const; | ||||
iterator FindByOffset(int utc_offset); | ||||
const_iterator FindByOffset(int utc_offset) const; | ||||
void Dump(std::ostream &os) const; | ||||
}; | ||||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const TimeZones | ||||
&l) | ||||
{ | ||||
l.Dump(os); | ||||
return os; | ||||
} | ||||
} // namespace Barry | } // namespace Barry | |||
#endif /* __BARRY_RECORD_TIMEZONE_H__*/ | #endif /* __BARRY_RECORD_TIMEZONE_H__*/ | |||
End of changes. 11 change blocks. | ||||
17 lines changed or deleted | 162 lines changed or added | |||
record.h | record.h | |||
---|---|---|---|---|
skipping to change at line 12 | skipping to change at line 12 | |||
/// \file record.h | /// \file record.h | |||
/// Blackberry database record classes. Help translate data | /// Blackberry database record classes. Help translate data | |||
/// from data packets to useful structurs, and back. | /// from data packets to useful structurs, and back. | |||
/// This header provides the common types and classes | /// This header provides the common types and classes | |||
/// used by the general record parser classes in the | /// used by the general record parser classes in the | |||
/// r_*.h files. Only application-safe API stuff goes in | /// r_*.h files. Only application-safe API stuff goes in | |||
/// here. Internal library types go in record-internal.h | /// here. Internal library types go in record-internal.h | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 36 | skipping to change at line 36 | |||
#ifndef __BARRY_RECORD_H__ | #ifndef __BARRY_RECORD_H__ | |||
#define __BARRY_RECORD_H__ | #define __BARRY_RECORD_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include <iosfwd> | #include <iosfwd> | |||
#include <string> | #include <string> | |||
#include <vector> | #include <vector> | |||
#include <map> | #include <map> | |||
#include <stdint.h> | #include <stdint.h> | |||
#include <stdexcept> | ||||
// forward declarations | // forward declarations | |||
namespace Barry { class Data; } | namespace Barry { class Data; } | |||
namespace Barry { | namespace Barry { | |||
// | // | |||
// NOTE: All classes here must be container-safe! Perhaps add sorting | // NOTE: All classes here must be container-safe! Perhaps add sorting | |||
// operators in the future. | // operators in the future. | |||
// | // | |||
skipping to change at line 61 | skipping to change at line 62 | |||
friend std::ostream& operator<< (std::ostream &os, const Cr2LfWrappe r &str); | friend std::ostream& operator<< (std::ostream &os, const Cr2LfWrappe r &str); | |||
const std::string &m_str; | const std::string &m_str; | |||
public: | public: | |||
explicit Cr2LfWrapper(const std::string &str) | explicit Cr2LfWrapper(const std::string &str) | |||
: m_str(str) | : m_str(str) | |||
{ | { | |||
} | } | |||
}; | }; | |||
BXEXPORT std::ostream& operator<< (std::ostream &os, const Cr2LfWrapper &st r); | BXEXPORT std::ostream& operator<< (std::ostream &os, const Cr2LfWrapper &st r); | |||
/// Struct wrapper for time_t, to make sure that it has its own type, | ||||
/// for overload purposes. Some systems, like QNX, use a uint32_t typedef. | ||||
/// | ||||
/// If Time contains 0, it is considered invalid/uninitialized when using | ||||
/// IsValid(). Validity has no affect on comparison operators. | ||||
struct BXEXPORT TimeT | ||||
{ | ||||
time_t Time; | ||||
TimeT() | ||||
: Time(0) | ||||
{ | ||||
} | ||||
explicit TimeT(time_t t) | ||||
: Time(t) | ||||
{ | ||||
} | ||||
void clear() | ||||
{ | ||||
Time = 0; | ||||
} | ||||
bool IsValid() const { return Time > 0; } | ||||
bool operator< (const Barry::TimeT &other) const | ||||
{ | ||||
return Time < other.Time; | ||||
} | ||||
bool operator== (const Barry::TimeT &other) const | ||||
{ | ||||
return Time == other.Time; | ||||
} | ||||
bool operator!= (const Barry::TimeT &other) const | ||||
{ | ||||
return !operator==(other); | ||||
} | ||||
}; | ||||
BXEXPORT std::ostream& operator<< (std::ostream &os, const TimeT &t); | ||||
struct BXEXPORT CommandTableCommand | struct BXEXPORT CommandTableCommand | |||
{ | { | |||
unsigned int Code; | unsigned int Code; | |||
std::string Name; | std::string Name; | |||
}; | }; | |||
class BXEXPORT CommandTable | class BXEXPORT CommandTable | |||
{ | { | |||
public: | public: | |||
typedef CommandTableCommand Command; | typedef CommandTableCommand Command; | |||
skipping to change at line 171 | skipping to change at line 215 | |||
const unsigned char *end); | const unsigned char *end); | |||
public: | public: | |||
DatabaseDatabase(); | DatabaseDatabase(); | |||
~DatabaseDatabase(); | ~DatabaseDatabase(); | |||
void Parse(const Data &data); | void Parse(const Data &data); | |||
void Clear(); | void Clear(); | |||
void SortByName(); | void SortByName(); | |||
void SortByRecordCount(); | ||||
unsigned int GetTotalRecordCount() const; | ||||
// returns true on success, and fills target | // returns true on success, and fills target | |||
bool GetDBNumber(const std::string &name, unsigned int &number) cons t; | bool GetDBNumber(const std::string &name, unsigned int &number) cons t; | |||
bool GetDBName(unsigned int number, std::string &name) const; | bool GetDBName(unsigned int number, std::string &name) const; | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
}; | }; | |||
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const DatabaseDa tabase &dbdb) { | BXEXPORT inline std::ostream& operator<<(std::ostream &os, const DatabaseDa tabase &dbdb) { | |||
dbdb.Dump(os); | dbdb.Dump(os); | |||
skipping to change at line 192 | skipping to change at line 238 | |||
} | } | |||
struct UnknownData | struct UnknownData | |||
{ | { | |||
std::string raw_data; | std::string raw_data; | |||
const std::string::value_type* data() const { return raw_data.data() ; } | const std::string::value_type* data() const { return raw_data.data() ; } | |||
std::string::size_type size() const { return raw_data.size(); } | std::string::size_type size() const { return raw_data.size(); } | |||
void assign(const std::string::value_type *s, std::string::size_type n) | void assign(const std::string::value_type *s, std::string::size_type n) | |||
{ raw_data.assign(s, n); } | { raw_data.assign(s, n); } | |||
bool operator==(const UnknownData &other) const | ||||
{ | ||||
return raw_data == other.raw_data; | ||||
} | ||||
bool operator!=(const UnknownData &other) const | ||||
{ | ||||
return !operator==(other); | ||||
} | ||||
bool operator< (const UnknownData &other) const | ||||
{ | ||||
return raw_data < other.raw_data; | ||||
} | ||||
}; | }; | |||
struct BXEXPORT UnknownField | struct BXEXPORT UnknownField | |||
{ | { | |||
uint8_t type; | uint8_t type; | |||
UnknownData data; | UnknownData data; | |||
bool operator==(const UnknownField &other) const | ||||
{ | ||||
return type == other.type && | ||||
data == other.data; | ||||
} | ||||
bool operator!=(const UnknownField &other) const | ||||
{ | ||||
return !operator==(other); | ||||
} | ||||
bool operator< (const UnknownField &other) const | ||||
{ | ||||
return type < other.type && data < other.data; | ||||
} | ||||
}; | }; | |||
typedef std::vector<UnknownField> UnknownsType; | typedef std::vector<UnknownField> UnknownsType; | |||
BXEXPORT std::ostream& operator<< (std::ostream &os, const UnknownsType &un knowns); | BXEXPORT std::ostream& operator<< (std::ostream &os, const UnknownsType &un knowns); | |||
// simple string email type and list... keep this a simple string list, | ||||
// so it can be reused for other address-like data, like phone numbers. | ||||
// If you need something more complex, use EmailAddress below or | ||||
// create a new type. | ||||
typedef std::string EmailType; | ||||
class BXEXPORT EmailList : public std::vector<EmailType> | ||||
{ | ||||
public: | ||||
typedef std::vector<EmailType> base_type; | ||||
public: | ||||
using base_type::size; | ||||
using base_type::begin; | ||||
using base_type::end; | ||||
using base_type::at; | ||||
using base_type::rbegin; | ||||
using base_type::rend; | ||||
using base_type::empty; | ||||
using base_type::resize; | ||||
using base_type::reserve; | ||||
using base_type::front; | ||||
using base_type::back; | ||||
using base_type::push_back; | ||||
using base_type::pop_back; | ||||
using base_type::insert; | ||||
using base_type::erase; | ||||
using base_type::swap; | ||||
using base_type::clear; | ||||
using base_type::operator=; | ||||
using base_type::operator[]; | ||||
}; | ||||
BXEXPORT std::ostream& operator<< (std::ostream &os, const EmailList &list) | ||||
; | ||||
// struct, attempting to combine name + email address, for mail | ||||
struct BXEXPORT EmailAddress | struct BXEXPORT EmailAddress | |||
{ | { | |||
std::string Name; | std::string Name; | |||
std::string Email; | std::string Email; | |||
EmailAddress() | ||||
{ | ||||
} | ||||
/// Converts "Name <address@host.com>" into Name + Address | ||||
/// Will also handle just a plain address too. | ||||
explicit EmailAddress(const std::string &complex_address); | ||||
void clear() | void clear() | |||
{ | { | |||
Name.clear(); | Name.clear(); | |||
Email.clear(); | Email.clear(); | |||
} | } | |||
size_t size() const | size_t size() const | |||
{ | { | |||
return Name.size() + Email.size(); | return Name.size() + Email.size(); | |||
} | } | |||
bool operator==(const EmailAddress &other) const | ||||
{ | ||||
return Name == other.Name && | ||||
Email == other.Email; | ||||
} | ||||
bool operator!=(const EmailAddress &other) const | ||||
{ | ||||
return !operator==(other); | ||||
} | ||||
bool operator< (const EmailAddress &other) const | ||||
{ | ||||
// sort by email only, since not every address has a name | ||||
return Email < other.Email; | ||||
} | ||||
}; | }; | |||
BXEXPORT std::ostream& operator<<(std::ostream &os, const EmailAddress &msg a); | BXEXPORT std::ostream& operator<<(std::ostream &os, const EmailAddress &msg a); | |||
typedef std::vector<EmailAddress> EmailAddressList; | class BXEXPORT EmailAddressList : public std::vector<EmailAddress> | |||
{ | ||||
public: | ||||
std::string ToCommaSeparated() const; | ||||
void AddCommaSeparated(const std::string &list); | ||||
}; | ||||
BXEXPORT std::ostream& operator<<(std::ostream &os, const EmailAddressList &elist); | BXEXPORT std::ostream& operator<<(std::ostream &os, const EmailAddressList &elist); | |||
struct BXEXPORT PostalAddress | struct BXEXPORT PostalAddress | |||
{ | { | |||
std::string | std::string | |||
Address1, | Address1, | |||
Address2, | Address2, | |||
Address3, | Address3, | |||
City, | City, | |||
Province, | Province, | |||
PostalCode, | PostalCode, | |||
Country; | Country; | |||
std::string GetLabel() const; | std::string GetLabel() const; | |||
void Clear(); | void Clear(); | |||
bool HasData() const { return Address1.size() || Address2.size() || | bool HasData() const { return Address1.size() || Address2.size() || | |||
Address3.size() || City.size() || Province.size() || | Address3.size() || City.size() || Province.size() || | |||
PostalCode.size() || Country.size(); } | PostalCode.size() || Country.size(); } | |||
bool operator==(const PostalAddress &other) const | ||||
{ | ||||
return Address1 == other.Address1 && | ||||
Address2 == other.Address2 && | ||||
Address3 == other.Address3 && | ||||
City == other.City && | ||||
Province == other.Province && | ||||
PostalCode == other.PostalCode && | ||||
Country == other.Country; | ||||
} | ||||
bool operator!=(const PostalAddress &other) const | ||||
{ | ||||
return !operator==(other); | ||||
} | ||||
bool operator< (const PostalAddress &other) const | ||||
{ | ||||
return GetLabel() < other.GetLabel(); | ||||
} | ||||
}; | }; | |||
BXEXPORT std::ostream& operator<<(std::ostream &os, const PostalAddress &ms ga); | BXEXPORT std::ostream& operator<<(std::ostream &os, const PostalAddress &ms ga); | |||
struct BXEXPORT Date | struct BXEXPORT Date | |||
{ | { | |||
int Month; // 0 to 11 | int Month; // 0 to 11 | |||
int Day; // 1 to 31 | int Day; // 1 to 31 | |||
int Year; // exact number, eg. 2008 | int Year; // exact number, eg. 2008 | |||
Date() : Month(0), Day(0), Year(0) {} | Date() : Month(0), Day(0), Year(0) {} | |||
skipping to change at line 263 | skipping to change at line 424 | |||
void Clear(); | void Clear(); | |||
void ToTm(struct tm *timep) const; | void ToTm(struct tm *timep) const; | |||
std::string ToYYYYMMDD() const; | std::string ToYYYYMMDD() const; | |||
std::string ToBBString() const; // converts to Blackberry string | std::string ToBBString() const; // converts to Blackberry string | |||
// format of DD/MM/YYYY | // format of DD/MM/YYYY | |||
bool FromTm(const struct tm *timep); | bool FromTm(const struct tm *timep); | |||
bool FromBBString(const std::string &str); | bool FromBBString(const std::string &str); | |||
bool FromYYYYMMDD(const std::string &str); | bool FromYYYYMMDD(const std::string &str); | |||
bool operator==(const Date &other) const | ||||
{ | ||||
return Month == other.Month && | ||||
Day == other.Day && | ||||
Year == other.Year; | ||||
} | ||||
bool operator!=(const Date &other) const | ||||
{ | ||||
return !operator==(other); | ||||
} | ||||
bool operator< (const Date &other) const | ||||
{ | ||||
// YYYYMMDD as integer | ||||
unsigned int v1 = Year * 10000 + Month * 100 + Day; | ||||
unsigned int v2 = other.Year * 10000 + other.Month * 100 + o | ||||
ther.Day; | ||||
return v1 < v2; | ||||
} | ||||
}; | }; | |||
BXEXPORT std::ostream& operator<<(std::ostream &os, const Date &date); | BXEXPORT std::ostream& operator<<(std::ostream &os, const Date &date); | |||
class BXEXPORT CategoryList : public std::vector<std::string> | class BXEXPORT CategoryList : public std::vector<std::string> | |||
{ | { | |||
public: | public: | |||
/// Parses the given comma delimited category string into | /// Parses the given comma delimited category string into | |||
/// this CategoryList object, appending each token to the vector. | /// this CategoryList object, appending each token to the vector. | |||
/// Will clear vector beforehand. | /// Will clear vector beforehand. | |||
void CategoryStr2List(const std::string &str); | void CategoryStr2List(const std::string &str); | |||
/// Turns the current vectory into a comma delimited category | /// Turns the current vectory into a comma delimited category | |||
/// string suitable for use in Calendar, Task, and Memo | /// string suitable for use in Calendar, Task, and Memo | |||
/// protocol values. | /// protocol values. | |||
void CategoryList2Str(std::string &str) const; | void CategoryList2Str(std::string &str) const; | |||
using std::vector<std::string>::operator=; | using std::vector<std::string>::operator=; | |||
}; | }; | |||
BXEXPORT std::ostream& operator<<(std::ostream &os, const CategoryList &cl) | ||||
; | ||||
/////////////////////////////////////////////////////////////////////////// | ||||
/// | ||||
// Generic Field Handles | ||||
/// \addtogroup GenericFieldHandles | ||||
/// Generic field handle classes, used to reference and work | ||||
/// with record members in a flexible, indirect way. | ||||
/// | ||||
/// There are two ways to access device record data. The obviou | ||||
s | ||||
/// way is to instantiate a record class, such as Contact, and | ||||
/// access the public data members of that class to read and | ||||
/// write. If you always work with the same record class, this | ||||
/// works fine. | ||||
/// | ||||
/// The other way is to have a list of pointers to members. | ||||
/// For example, you may wish to compare two records, without | ||||
/// actually caring what data is in each one. You can compare | ||||
/// at the record class level, with Contact one, two; and then | ||||
/// if( one == two ), but this will not tell you what field in | ||||
/// the record changed. | ||||
/// | ||||
/// This last feature is what Generic Field Handles are meant to | ||||
/// fix. Each record class will contain a GetFieldHandles() | ||||
/// member function, which will return a list of type | ||||
/// FieldHandle<T>::ListT (currently a std::vector<>) | ||||
/// objects, for that specific record. For example, Contact | ||||
/// would fill the ListT with FieldHandle<Contact> objects. | ||||
/// Each FieldHandle<> object contains a C++ pointer-to-member, | ||||
/// which the FieldHandle refers to, as well as a FieldIdentity | ||||
/// object. The FieldIdentity object contains various identityi | ||||
ng | ||||
/// information, such as the C++ variable name, an English | ||||
/// (or localized language) display name of the field, suitable | ||||
/// for user prompts, and other data more useful to the library. | ||||
/// | ||||
/// The FieldHandle<> object has two member functions: Value() | ||||
/// and Member(). | ||||
/// | ||||
/// Value() will call a callback function with the _value_ of | ||||
/// the variable that FieldHandle<> points to. For example, | ||||
/// if the FieldHandle<> points to a std::string record member | ||||
/// variable, then Value() will pass that string value in as | ||||
/// an argument, along with a reference to the FieldIdentity | ||||
/// object. Value() requires a callback object and a record | ||||
/// object to perform this callback. | ||||
/// | ||||
/// Member() will call a callback function/functor with the | ||||
/// pointer-to-member pointer and the FieldIdentity object. | ||||
/// This allows the programmer to create a functor with multiple | ||||
/// record objects, perhaps two objects to compare individual | ||||
/// fields, and use the pointer-to-member to access the field | ||||
/// data as needed. | ||||
/// | ||||
/// For now, all data and callbacks are const, meaning that it | ||||
/// is not possible (without const_casting) to write to the | ||||
/// record via the pointers-to-members. This design decision | ||||
/// may need to be revisited someday, depending on its usefulnes | ||||
s. | ||||
/// | ||||
/// @{ | ||||
// | ||||
// FieldIdentity | ||||
// | ||||
/// This class holds data that identifies a given field in a record. | ||||
/// This is fairly constant data, referenced by the FieldHandle class. | ||||
/// The information in here should be enough to show the user what kind | ||||
/// of field this is. | ||||
/// | ||||
struct BXEXPORT FieldIdentity | ||||
{ | ||||
// useful public data | ||||
const char *Name; // C++ name of field member variable | ||||
in | ||||
// record class | ||||
std::string DisplayName; // localized display name of field | ||||
// in UTF8 | ||||
// FIXME - should we leave localizat | ||||
ion | ||||
// to the application? | ||||
// subfield detection | ||||
bool HasSubfields; // true if this field has subfields | ||||
const char *ParentName; // name of field member variable tha | ||||
t | ||||
// this field is a member of, or NUL | ||||
L | ||||
// if this field is a member of the | ||||
// record class. | ||||
// For example, Contact::PostalAddre | ||||
ss | ||||
// would have HasSubfields == true, | ||||
// and ParentName == NULL, while all | ||||
// its subfield strings would have | ||||
// HasSubfields == false and | ||||
// ParentName == "WorkAddress" or | ||||
// "HomeAddress". | ||||
// The application could then decide | ||||
// whether to process only main fiel | ||||
ds, | ||||
// some of which have subfields, | ||||
// or only individual subfields. | ||||
// internal field data | ||||
int FieldTypeCode; // device type code for this field. | ||||
// if -1, then this is a conglomerat | ||||
e | ||||
// C++ field, such as | ||||
// Contact::PostalAddress, not a dev | ||||
ice | ||||
// field. | ||||
// If -1, then none of the following | ||||
// fields are valid. | ||||
const char *Ldif; // matching LDIF field name, or NULL | ||||
const char *ObjectClass; // matching LDIF object class, or NU | ||||
LL | ||||
bool IconvNeeded; // if true, the device's data needs | ||||
to | ||||
// be passed through an IConverter | ||||
FieldIdentity(const char *name, const std::string &display_name, | ||||
int type_code = -1, | ||||
bool iconvneeded = false, | ||||
const char *ldif = 0, const char *oclass = 0, | ||||
bool has_sub = false, const char *parent = 0 | ||||
) | ||||
: Name(name) | ||||
, DisplayName(display_name) | ||||
, HasSubfields(has_sub) | ||||
, ParentName(parent) | ||||
, FieldTypeCode(type_code) | ||||
, Ldif(ldif) | ||||
, ObjectClass(oclass) | ||||
, IconvNeeded(iconvneeded) | ||||
{ | ||||
} | ||||
}; | ||||
// | ||||
// EnumConstants | ||||
// | ||||
/// This is the base class for the hierarchy of classes to define | ||||
/// enum record members. This is the base class, which contains the | ||||
/// common code for creating and defining a list of enum constants for | ||||
/// a given enum field. The next derived class is EnumFieldBase<RecordT>, | ||||
/// which defines the virtual API for talking to a given enum field | ||||
/// in a given record. The next derived class is EnumField<RecordT, EnumT> | ||||
, | ||||
/// which implements the pointer-to-member and virtual API for a given | ||||
/// enum type in a given record class. | ||||
/// | ||||
/// For example, the Bookmark record class has the following enum field: | ||||
/// | ||||
/// <pre> | ||||
/// enum BrowserIdentityType | ||||
/// { | ||||
/// IdentityAuto = 0, | ||||
/// IdentityBlackBerry, | ||||
/// IdentityFireFox, | ||||
/// IdentityInternetExplorer, | ||||
/// IdentityUnknown | ||||
/// }; | ||||
/// BrowserIdentityType BrowserIdentity; | ||||
/// </pre> | ||||
/// | ||||
/// The EnumConstants class will hold a vector of EnumConstant structs | ||||
/// defining each of the identity constants: Auto, BlackBerry, FireFox, | ||||
/// InternetExplorer, and Unknown. | ||||
/// | ||||
/// The derived class EnumFieldBase<Bookmark> will define two additional | ||||
/// pure virtual API calls: GetValue(const Bookmark&) and | ||||
/// SetValue(Bookmark&, int). | ||||
/// | ||||
/// Finally, the derived class EnumField<Bookmark,Bookmark::BrowserIdentity | ||||
Type> | ||||
/// will implement the virtual API, and contain a pointer-to-member to | ||||
/// the Bookmark::BrowserIdentity member field. | ||||
/// | ||||
/// The FieldHandle<Bookmark> class will hold a pointer to | ||||
/// EnumFieldBase<Bookmark>, which can hold a pointer to a specific | ||||
/// EnumField<> object, one object for each of Bookmark's enum types, | ||||
/// of which there are currently 3. | ||||
/// | ||||
class BXEXPORT EnumConstants | ||||
{ | ||||
public: | ||||
/// This defines one of the enum constants being defined. | ||||
/// For example, for an enum declaration like: | ||||
/// enum Mine { A, B, C }; then this struct could contain | ||||
/// a definition for A, B, or C, but only one at at time. | ||||
/// All three would be defined by the EnumConstantList. | ||||
struct EnumConstant | ||||
{ | ||||
const char *Name; //< C++ name of enum constan | ||||
t | ||||
std::string DisplayName; //< user-friendly name / mea | ||||
ning | ||||
int Value; //< constant enum value | ||||
EnumConstant(const char *name, const std::string &display, | ||||
int value) | ||||
: Name(name) | ||||
, DisplayName(display) | ||||
, Value(value) | ||||
{ | ||||
} | ||||
}; | ||||
typedef std::vector<EnumConstant> EnumConstantList; | ||||
private: | ||||
EnumConstantList m_constants; | ||||
public: | ||||
virtual ~EnumConstants() {} | ||||
/// Adds a constant definition to the list | ||||
void AddConstant(const char *name, const std::string &display, int v | ||||
al); | ||||
/// Returns a vector of EnumConstant objects, describing all enum | ||||
/// constants valid for this enum field. | ||||
const EnumConstantList& GetConstantList() const { return m_constants | ||||
; } | ||||
/// Returns the EnumConstant for the given value. | ||||
/// Throws std::logic_error if not found. | ||||
const EnumConstant& GetConstant(int value) const; | ||||
/// Returns the constant name (C++ name) based on the given value. | ||||
/// Throws std::logic_error if not found. | ||||
const char* GetName(int value) const; | ||||
/// Returns the display name based on the given value. | ||||
/// Throws std::logic_error if not found. | ||||
const std::string& GetDisplayName(int value) const; | ||||
/// Returns true if the value matches one of the constants in the li | ||||
st. | ||||
bool IsConstantValid(int value) const; | ||||
}; | ||||
// | ||||
// FieldValueHandlerBase | ||||
// | ||||
/// This is a pure virtual base class, defining the various types that | ||||
/// record fields can be. To be able to handle all the types of data | ||||
/// in all records, override these virtual functions to do with the | ||||
/// data as you wish. | ||||
/// | ||||
/// All data from the records and fields will be passed in by value. | ||||
/// i.e. if field is string data, the overloaded std::string handler | ||||
/// will be called, and a refernce to the string will be passed in. | ||||
/// | ||||
/// The advantage of using this virtual class is that less code will be | ||||
/// generated by templates. The disadvantage is that this is less flexible | ||||
. | ||||
/// You will only get called for one field and record at a time. | ||||
/// So you can't do comparisons this way. | ||||
/// | ||||
class BXEXPORT FieldValueHandlerBase | ||||
{ | ||||
public: | ||||
virtual ~FieldValueHandlerBase() {} | ||||
/// For type std::string | ||||
virtual void operator()(const std::string &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type EmailAddressList | ||||
virtual void operator()(const EmailAddressList &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type Barry::TimeT | ||||
virtual void operator()(const Barry::TimeT &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type uint8_t | ||||
virtual void operator()(const uint8_t &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type uint16_t | ||||
virtual void operator()(const uint16_t &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type uint32_t | ||||
virtual void operator()(const uint32_t &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type uint64_t | ||||
virtual void operator()(const uint64_t &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type bool | ||||
virtual void operator()(const bool &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type int32_t | ||||
virtual void operator()(const int32_t &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type EmailList | ||||
virtual void operator()(const EmailList &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type Date | ||||
virtual void operator()(const Date &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type CategoryList | ||||
virtual void operator()(const CategoryList &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type PostalAddress | ||||
virtual void operator()(const PostalAddress &v, | ||||
const FieldIdentity &id) const = 0; | ||||
/// For type UnknownsType | ||||
virtual void operator()(const UnknownsType &v, | ||||
const FieldIdentity &id) const = 0; | ||||
}; | ||||
/// | ||||
/// EnumFieldBase<RecordT> | ||||
/// | ||||
template <class RecordT> | ||||
class EnumFieldBase : public EnumConstants | ||||
{ | ||||
public: | ||||
/// Return value of enum in rec | ||||
virtual int GetValue(const RecordT &rec) const = 0; | ||||
/// Set value of enum in rec | ||||
/// Throws std::logic_error if value is out of range | ||||
virtual void SetValue(RecordT &rec, int value) = 0; | ||||
}; | ||||
/// | ||||
/// EnumField<RecordT, EnumT> | ||||
/// | ||||
template <class RecordT, class EnumT> | ||||
class EnumField : public EnumFieldBase<RecordT> | ||||
{ | ||||
EnumT RecordT::* m_mp; | ||||
public: | ||||
explicit EnumField(EnumT RecordT::* mp) | ||||
: m_mp(mp) | ||||
{ | ||||
} | ||||
virtual int GetValue(const RecordT &rec) const | ||||
{ | ||||
return rec.*m_mp; | ||||
} | ||||
virtual void SetValue(RecordT &rec, int value) | ||||
{ | ||||
if( !this->IsConstantValid(value) ) | ||||
throw std::logic_error("Bad enum value in EnumField" | ||||
); | ||||
rec.*m_mp = (EnumT) value; | ||||
} | ||||
}; | ||||
// | ||||
// FieldHandle<RecordT> | ||||
// | ||||
/// This is a template class that handles pointers to members of multiple | ||||
/// types of data and multiple types of records. | ||||
/// | ||||
/// This class contains a union of all known data pointers in all records. | ||||
/// Therefore this class can hold a pointer to member of any record class. | ||||
/// | ||||
/// To do something with the field that this FieldHandle<> class refers to, | ||||
/// call either Value() or Member() with appropriate callback functors. | ||||
/// Value will pass a reference to the field. You can use an object | ||||
/// derived from FieldValueHandlerBase here. Member() will pass a pointer | ||||
/// to member. Your functor will need to contain the record data in order | ||||
/// to access its data via the pointer to member. | ||||
/// | ||||
/// The template functor callback that you pass into member must be | ||||
/// capable of this: | ||||
/// | ||||
/// <pre> | ||||
/// template <class RecordT> | ||||
/// struct Callback | ||||
/// { | ||||
/// RecordT m_rec; | ||||
/// | ||||
/// void operator()(typename FieldHandle<RecordT>::PostalPointer | ||||
pp, | ||||
/// const FieldIdentity &id) const | ||||
/// { | ||||
/// PostalAddress pa = m_rec.*(pp.m_PostalAddress); | ||||
/// std::string val = pa.*(pp.m_PostalField); | ||||
/// ... | ||||
/// } | ||||
/// | ||||
/// template <class TypeT> | ||||
/// void operator()(TypeT RecordT::* mp, | ||||
/// const FieldIdentity &id) const | ||||
/// { | ||||
/// TypeT val = m_rec.*mp; | ||||
/// ... | ||||
/// } | ||||
/// }; | ||||
/// </pre> | ||||
/// | ||||
/// You don't have to use a TypeT template, but if you don't, then you must | ||||
/// support all field types that the record class you're processing uses. | ||||
/// | ||||
/// | ||||
template <class RecordT> | ||||
class FieldHandle | ||||
{ | ||||
public: | ||||
typedef FieldHandle<RecordT> Self; | ||||
typedef std::vector<Self> ListT; | ||||
// Need to use this in the union, so no constructor allowed | ||||
struct PostalPointer | ||||
{ | ||||
PostalAddress RecordT::* m_PostalAddress; | ||||
std::string PostalAddress::* m_PostalField; | ||||
}; | ||||
// So use a factory function | ||||
static PostalPointer MakePostalPointer(PostalAddress RecordT::* p1, | ||||
std::string PostalAddress::* p2) | ||||
{ | ||||
PostalPointer pp; | ||||
pp.m_PostalAddress = p1; | ||||
pp.m_PostalField = p2; | ||||
return pp; | ||||
} | ||||
private: | ||||
union PointerUnion | ||||
{ | ||||
std::string RecordT::* m_string; // index 0 | ||||
EmailAddressList RecordT::* m_EmailAddressList; // 1 | ||||
Barry::TimeT RecordT::* m_time; // 2 | ||||
PostalPointer m_postal; // 3 | ||||
uint8_t RecordT::* m_uint8; // 4 | ||||
uint32_t RecordT::* m_uint32; // 5 | ||||
EmailList RecordT::* m_EmailList; // 6 | ||||
Date RecordT::* m_Date; // 7 | ||||
CategoryList RecordT::* m_CategoryList; // 8 | ||||
// GroupLinksType RecordT::* m_GroupLinksType; // 9 | ||||
UnknownsType RecordT::* m_UnknownsType; // 10 | ||||
bool RecordT::* m_bool; // 11 | ||||
uint64_t RecordT::* m_uint64; // 12 | ||||
uint16_t RecordT::* m_uint16; // 13 | ||||
PostalAddress RecordT::* m_PostalAddress; // 14 | ||||
// used by non-union m_enum below: // 15 | ||||
int32_t RecordT::* m_int32; // 16 | ||||
}; | ||||
int m_type_index; | ||||
PointerUnion m_union; | ||||
EnumFieldBase<RecordT> *m_enum; // never freed, since this is a | ||||
// static list, existing to end of | ||||
// program lifetime | ||||
FieldIdentity m_id; | ||||
public: | ||||
// 0 | ||||
FieldHandle(std::string RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(0) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_string = mp; | ||||
} | ||||
// 1 | ||||
FieldHandle(EmailAddressList RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(1) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_EmailAddressList = mp; | ||||
} | ||||
// 2 | ||||
FieldHandle(Barry::TimeT RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(2) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_time = mp; | ||||
} | ||||
// 3 | ||||
FieldHandle(const PostalPointer &pp, const FieldIdentity &id) | ||||
: m_type_index(3) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_postal = pp; | ||||
} | ||||
// 4 | ||||
FieldHandle(uint8_t RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(4) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_uint8 = mp; | ||||
} | ||||
// 5 | ||||
FieldHandle(uint32_t RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(5) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_uint32 = mp; | ||||
} | ||||
// 6 | ||||
FieldHandle(EmailList RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(6) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_EmailList = mp; | ||||
} | ||||
// 7 | ||||
FieldHandle(Date RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(7) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_Date = mp; | ||||
} | ||||
// 8 | ||||
FieldHandle(CategoryList RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(8) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_CategoryList = mp; | ||||
} | ||||
// 9 | ||||
// FieldHandle(GroupLinksType RecordT::* mp, const FieldIdentity &id) | ||||
// : m_type_index(9) | ||||
// , m_enum(0) | ||||
// , m_id(id) | ||||
// { | ||||
// m_union.m_GroupLinksType = mp; | ||||
// } | ||||
// 10 | ||||
FieldHandle(UnknownsType RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(10) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_UnknownsType = mp; | ||||
} | ||||
// 11 | ||||
FieldHandle(bool RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(11) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_bool = mp; | ||||
} | ||||
// 12 | ||||
FieldHandle(uint64_t RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(12) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_uint64 = mp; | ||||
} | ||||
// 13 | ||||
FieldHandle(uint16_t RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(13) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_uint16 = mp; | ||||
} | ||||
// 14 | ||||
FieldHandle(PostalAddress RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(14) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_PostalAddress = mp; | ||||
} | ||||
// 15 | ||||
FieldHandle(EnumFieldBase<RecordT> *enum_, const FieldIdentity &id) | ||||
: m_type_index(15) | ||||
, m_enum(enum_) | ||||
, m_id(id) | ||||
{ | ||||
} | ||||
// 16 | ||||
FieldHandle(int32_t RecordT::* mp, const FieldIdentity &id) | ||||
: m_type_index(16) | ||||
, m_enum(0) | ||||
, m_id(id) | ||||
{ | ||||
m_union.m_int32 = mp; | ||||
} | ||||
/// Extracts FieldIdentity object from FieldHandle<> | ||||
const FieldIdentity& GetIdentity() const { return m_id; } | ||||
/// Calls the matching virtual function in FieldValueHandlerBase, | ||||
/// passing in the value of the field that this FieldHandle<> | ||||
/// refers to, and a referenct to the FieldIdentity object. | ||||
/// Caller must pass in a RecordT object as well. | ||||
void Value(const FieldValueHandlerBase &vh, const RecordT &rec) cons | ||||
t | ||||
{ | ||||
switch( m_type_index ) | ||||
{ | ||||
case 0: | ||||
vh(rec.*(m_union.m_string), m_id); | ||||
break; | ||||
case 1: | ||||
vh(rec.*(m_union.m_EmailAddressList), m_id); | ||||
break; | ||||
case 2: | ||||
vh(rec.*(m_union.m_time), m_id); | ||||
break; | ||||
case 3: | ||||
vh(rec.*(m_union.m_postal.m_PostalAddress).*(m_union | ||||
.m_postal.m_PostalField), m_id); | ||||
break; | ||||
case 4: | ||||
vh(rec.*(m_union.m_uint8), m_id); | ||||
break; | ||||
case 5: | ||||
vh(rec.*(m_union.m_uint32), m_id); | ||||
break; | ||||
case 6: | ||||
vh(rec.*(m_union.m_EmailList), m_id); | ||||
break; | ||||
case 7: | ||||
vh(rec.*(m_union.m_Date), m_id); | ||||
break; | ||||
case 8: | ||||
vh(rec.*(m_union.m_CategoryList), m_id); | ||||
break; | ||||
// case 9: | ||||
// vh(rec.*(m_union.m_GroupLinksType), m_id); | ||||
// break; | ||||
case 10: | ||||
vh(rec.*(m_union.m_UnknownsType), m_id); | ||||
break; | ||||
case 11: | ||||
vh(rec.*(m_union.m_bool), m_id); | ||||
break; | ||||
case 12: | ||||
vh(rec.*(m_union.m_uint64), m_id); | ||||
break; | ||||
case 13: | ||||
vh(rec.*(m_union.m_uint16), m_id); | ||||
break; | ||||
case 14: | ||||
vh(rec.*(m_union.m_PostalAddress), m_id); | ||||
break; | ||||
case 15: | ||||
vh(m_enum->GetValue(rec), m_id); | ||||
break; | ||||
case 16: | ||||
vh(rec.*(m_union.m_int32), m_id); | ||||
break; | ||||
default: | ||||
throw std::logic_error("Unknown field handle type in | ||||
dex"); | ||||
} | ||||
} | ||||
/// Calls the callback functor with two arguments: the pointer to | ||||
/// member that this FieldHandle<> contains, and the FieldIdentity | ||||
/// object. It is assumed that the functor will either contain | ||||
/// or know where to find one or more records of type RecordT. | ||||
template <class CallbackT> | ||||
void Member(const CallbackT &func) const | ||||
{ | ||||
switch( m_type_index ) | ||||
{ | ||||
case 0: | ||||
func(m_union.m_string, m_id); | ||||
break; | ||||
case 1: | ||||
func(m_union.m_EmailAddressList, m_id); | ||||
break; | ||||
case 2: | ||||
func(m_union.m_time, m_id); | ||||
break; | ||||
case 3: | ||||
func(m_union.m_postal, m_id); | ||||
break; | ||||
case 4: | ||||
func(m_union.m_uint8, m_id); | ||||
break; | ||||
case 5: | ||||
func(m_union.m_uint32, m_id); | ||||
break; | ||||
case 6: | ||||
func(m_union.m_EmailList, m_id); | ||||
break; | ||||
case 7: | ||||
func(m_union.m_Date, m_id); | ||||
break; | ||||
case 8: | ||||
func(m_union.m_CategoryList, m_id); | ||||
break; | ||||
// case 9: | ||||
// func(m_union.m_GroupLinksType, m_id); | ||||
// break; | ||||
case 10: | ||||
func(m_union.m_UnknownsType, m_id); | ||||
break; | ||||
case 11: | ||||
func(m_union.m_bool, m_id); | ||||
break; | ||||
case 12: | ||||
func(m_union.m_uint64, m_id); | ||||
break; | ||||
case 13: | ||||
func(m_union.m_uint16, m_id); | ||||
break; | ||||
case 14: | ||||
func(m_union.m_PostalAddress, m_id); | ||||
break; | ||||
case 15: | ||||
func(m_enum, m_id); | ||||
break; | ||||
case 16: | ||||
func(m_union.m_int32, m_id); | ||||
break; | ||||
default: | ||||
throw std::logic_error("Unknown field handle type in | ||||
dex"); | ||||
} | ||||
} | ||||
}; | ||||
/// Factory function to create a FieldHandle<> object. | ||||
template <class RecordT, class TypeT> | ||||
FieldHandle<RecordT> MakeFieldHandle(TypeT RecordT::* tp, | ||||
const FieldIdentity &id) | ||||
{ | ||||
return FieldHandle<RecordT>(tp, id); | ||||
} | ||||
/// Calls FieldHandle<>::Member() for each defined field for a given record | ||||
/// type. Takes a FieldHandle<>::ListT containing FieldHandle<> objects, | ||||
/// and calls Member(func) for each one. | ||||
template <class HandlesT, class CallbackT> | ||||
void ForEachField(const HandlesT &handles, const CallbackT &func) | ||||
{ | ||||
typename HandlesT::const_iterator | ||||
b = handles.begin(), | ||||
e = handles.end(); | ||||
for( ; b != e; ++b ) { | ||||
b->Member(func); | ||||
} | ||||
} | ||||
/// Calls FieldHandle<>::Value() for each defined field for a given record. | ||||
/// Takes a RecordT object and calls Value(vh, rec) for each FieldHandle<> | ||||
/// object in the record's FieldHandles set. | ||||
template <class RecordT> | ||||
void ForEachFieldValue(const RecordT &rec, const FieldValueHandlerBase &vh) | ||||
{ | ||||
typename FieldHandle<RecordT>::ListT::const_iterator | ||||
b = RecordT::GetFieldHandles().begin(), | ||||
e = RecordT::GetFieldHandles().end(); | ||||
for( ; b != e; ++b ) { | ||||
b->Value(vh, rec); | ||||
} | ||||
} | ||||
// | ||||
// FieldHandle setup macros | ||||
// | ||||
// #undef and #define the following macros to override these macros for you | ||||
: | ||||
// | ||||
// CONTAINER_OBJECT_NAME - the new FieldHandles will be .push_back()'d | ||||
into | ||||
// this container | ||||
// RECORD_CLASS_NAME - the name of the record class you are definin | ||||
g, | ||||
// i.e. Barry::Contact, or Barry::Calendar | ||||
// | ||||
// plain field, no connection to device field | ||||
#define FHP(name, display) \ | ||||
CONTAINER_OBJECT_NAME.push_back( \ | ||||
FieldHandle<RECORD_CLASS_NAME>(&RECORD_CLASS_NAME::name, \ | ||||
FieldIdentity(#name, display))) | ||||
// record field with direct connection to device field, no LDIF data | ||||
#define FHD(name, display, type_code, iconv) \ | ||||
CONTAINER_OBJECT_NAME.push_back( \ | ||||
FieldHandle<RECORD_CLASS_NAME>(&RECORD_CLASS_NAME::name, \ | ||||
FieldIdentity(#name, display, type_code, iconv, \ | ||||
0, 0))) | ||||
// record field with direct connection to device field, with LDIF data | ||||
#define FHL(name, display, type_code, iconv, ldif, oclass) \ | ||||
CONTAINER_OBJECT_NAME.push_back( \ | ||||
FieldHandle<RECORD_CLASS_NAME>(&RECORD_CLASS_NAME::name, \ | ||||
FieldIdentity(#name, display, type_code, iconv, \ | ||||
ldif, oclass))) | ||||
// a subfield of a conglomerate field, with direct connection to device fie | ||||
ld, | ||||
// with LDIF data | ||||
#define FHS(name, subname, display, type, iconv, ldif, oclass) \ | ||||
CONTAINER_OBJECT_NAME.push_back( \ | ||||
FieldHandle<RECORD_CLASS_NAME>( \ | ||||
FieldHandle<RECORD_CLASS_NAME>::MakePostalPointer( \ | ||||
&RECORD_CLASS_NAME::name, \ | ||||
&PostalAddress::subname), \ | ||||
FieldIdentity(#name "::" #subname, display, \ | ||||
type, iconv, ldif, oclass, \ | ||||
false, #name))) | ||||
// record conglomerate field, which has subfields | ||||
#define FHC(name, display) \ | ||||
CONTAINER_OBJECT_NAME.push_back( \ | ||||
FieldHandle<RECORD_CLASS_NAME>(&RECORD_CLASS_NAME::name, \ | ||||
FieldIdentity(#name, display, \ | ||||
-1, false, 0, 0, true, 0))) | ||||
// create a new EnumField<> and add it to the list... use the new_var_name | ||||
// to add constants with FHE_CONST below | ||||
#define FHE(new_var_name, record_field_type, record_field_name, display) \ | ||||
EnumField<RECORD_CLASS_NAME, RECORD_CLASS_NAME::record_field_type> \ | ||||
*new_var_name = new \ | ||||
EnumField<RECORD_CLASS_NAME, RECORD_CLASS_NAME::record_field | ||||
_type> \ | ||||
(&RECORD_CLASS_NAME::record_field_name); \ | ||||
CONTAINER_OBJECT_NAME.push_back( \ | ||||
FieldHandle<RECORD_CLASS_NAME>(new_var_name, \ | ||||
FieldIdentity(#record_field_name, display))) | ||||
// same as FHE, but for when RECORD_CLASS_NAME is a template argument | ||||
#define FHET(new_var_name, record_field_type, record_field_name, display) \ | ||||
EnumField<RECORD_CLASS_NAME, typename RECORD_CLASS_NAME::record_fiel | ||||
d_type> \ | ||||
*new_var_name = new \ | ||||
EnumField<RECORD_CLASS_NAME, typename RECORD_CLASS_NAME::rec | ||||
ord_field_type> \ | ||||
(&RECORD_CLASS_NAME::record_field_name); \ | ||||
CONTAINER_OBJECT_NAME.push_back( \ | ||||
FieldHandle<RECORD_CLASS_NAME>(new_var_name, \ | ||||
FieldIdentity(#record_field_name, display))) | ||||
// add constant to enum created above | ||||
#define FHE_CONST(var, name, display) \ | ||||
var->AddConstant(#name, display, RECORD_CLASS_NAME::name) | ||||
/// @} | ||||
} // namespace Barry | ||||
/// \addtogroup RecordParserClasses | /// \addtogroup RecordParserClasses | |||
/// Parser and data storage classes. These classes take a | /// Parser and data storage classes. These classes take a | |||
/// Database Database record and convert them into C++ objects. | /// Database Database record and convert them into C++ objects. | |||
/// Each of these classes are safe to be used in standard | /// Each of these classes are safe to be used in standard | |||
/// containers, and are meant to be used in conjunction with the | /// containers, and are meant to be used in conjunction with the | |||
/// RecordParser<> template when calling Controller::LoadDatabas e(). | /// RecordParser<> template when calling Controller::LoadDatabas e(). | |||
/// @{ | /// @{ | |||
/// @} | /// @} | |||
} // namespace Barry | ||||
#ifndef __BARRY_LIBRARY_BUILD__ | #ifndef __BARRY_LIBRARY_BUILD__ | |||
// Include all parser classes, to make it easy for the application to use. | // Include all parser classes, to make it easy for the application to use. | |||
#include "r_calendar.h" | #include "r_calendar.h" | |||
#include "r_calllog.h" | #include "r_calllog.h" | |||
#include "r_bookmark.h" | #include "r_bookmark.h" | |||
#include "r_contact.h" | #include "r_contact.h" | |||
#include "r_cstore.h" | #include "r_cstore.h" | |||
#include "r_memo.h" | #include "r_memo.h" | |||
#include "r_message.h" | #include "r_message.h" | |||
#include "r_servicebook.h" | #include "r_servicebook.h" | |||
#include "r_task.h" | #include "r_task.h" | |||
#include "r_pin_message.h" | #include "r_pin_message.h" | |||
#include "r_saved_message.h" | #include "r_saved_message.h" | |||
#include "r_sms.h" | #include "r_sms.h" | |||
#include "r_folder.h" | #include "r_folder.h" | |||
#include "r_timezone.h" | #include "r_timezone.h" | |||
#include "r_hhagent.h" | ||||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 15 change blocks. | ||||
4 lines changed or deleted | 1045 lines changed or added | |||
restore.h | restore.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file restore.h | /// \file restore.h | |||
/// Builder class for restoring from Barry Backup files | /// Builder class for restoring from Barry Backup files | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 82 | skipping to change at line 82 | |||
RS_EMPTY, // no record loaded | RS_EMPTY, // no record loaded | |||
RS_UNKNOWN, // record data loaded, but not yet checked | RS_UNKNOWN, // record data loaded, but not yet checked | |||
// whether this is part of current database | // whether this is part of current database | |||
RS_NEXT, // record loaded, part of current database | RS_NEXT, // record loaded, part of current database | |||
RS_DBEND, // next record loaded, but end-of-database | RS_DBEND, // next record loaded, but end-of-database | |||
// not yet processed by Builder API | // not yet processed by Builder API | |||
RS_EOF // no recrd loaded, end of tar file | RS_EOF // no recrd loaded, end of tar file | |||
}; | }; | |||
DBListType m_dbList; | DBListType m_dbList; | |||
DBListType m_dbSkipList; | ||||
std::string m_tarpath; | std::string m_tarpath; | |||
std::auto_ptr<reuse::TarFile> m_tar; | std::auto_ptr<reuse::TarFile> m_tar; | |||
bool m_default_all_db; | bool m_default_all_db; | |||
RetrievalState m_tar_record_state; | RetrievalState m_tar_record_state; | |||
uint8_t m_rec_type; | uint8_t m_rec_type; | |||
uint32_t m_unique_id; | uint32_t m_unique_id; | |||
std::string m_current_dbname; | std::string m_current_dbname; | |||
Barry::Data m_record_data; | Barry::Data m_record_data; | |||
skipping to change at line 119 | skipping to change at line 120 | |||
/// list takes precedence, and default_all_db has no effect. | /// list takes precedence, and default_all_db has no effect. | |||
/// | /// | |||
explicit Restore(const std::string &tarpath, | explicit Restore(const std::string &tarpath, | |||
bool default_all_db = true); | bool default_all_db = true); | |||
~Restore(); | ~Restore(); | |||
/// Add database name to the read filter. | /// Add database name to the read filter. | |||
void AddDB(const std::string &dbName); | void AddDB(const std::string &dbName); | |||
/// Add all database names in dblist to the read filter | /// Add all database names in dblist to the read filter | |||
/// This function is additive. | ||||
void Add(const DBListType &dbList); | void Add(const DBListType &dbList); | |||
/// Add all database names in the DBDB to the read filter | ||||
void Add(const DatabaseDatabase &dbdb); | ||||
/// Add database name to the skip list. The skip list prevents | ||||
/// any matching database from appearing in the restore process. | ||||
/// It is the converse of AddDB() in ultimate behaviour. | ||||
void AddSkipDB(const std::string &dbName); | ||||
// Skip the current DB, in case of error, or preference | // Skip the current DB, in case of error, or preference | |||
void SkipCurrentDB(); | void SkipCurrentDB(); | |||
/// Loads the given file, and counts all records according | /// Loads the given file, and counts all records according | |||
/// to the current read filter. Does not use the main | /// to the current read filter. Does not use the main | |||
/// Restore file, but opens the file separately. | /// Restore file, but opens the file separately. | |||
/// It is safe to call this function as often as needed. | /// It is safe to call this function as often as needed. | |||
unsigned int GetRecordTotal() const; | unsigned int GetRecordTotal() const; | |||
/// Static version of above call | /// Static version of above call | |||
static unsigned int GetRecordTotal(const std::string &tarpath, | static unsigned int GetRecordTotal(const std::string &tarpath, | |||
const DBListType &dbList, bool default_all_db); | const DBListType &dbList, bool default_all_db); | |||
/// Loads the given file, and creates a DBListType list of | ||||
/// all database names available in the tarball, using no filters. | ||||
/// Does not use the main Restore file, but opens the file separatel | ||||
y. | ||||
/// It is safe to call this function as often as needed. | ||||
DBListType GetDBList() const; | ||||
/// Static version of GetDBList() | ||||
static DBListType GetDBList(const std::string &tarpath); | ||||
/// If this function returns true, it fills data with the | /// If this function returns true, it fills data with the | |||
/// meta data that the next call to BuildRecord() will retrieve. | /// meta data that the next call to BuildRecord() will retrieve. | |||
/// This is useful for applications that need to setup a manual | /// This is useful for applications that need to setup a manual | |||
/// call to Desktop::SaveDatabase(). | /// call to Desktop::SaveDatabase(). | |||
bool GetNextMeta(DBData &data); | bool GetNextMeta(DBData &data); | |||
// Barry::Builder overrides | // Barry::Builder overrides | |||
bool BuildRecord(Barry::DBData &data, size_t &offset, | bool BuildRecord(Barry::DBData &data, size_t &offset, | |||
const Barry::IConverter *ic); | const Barry::IConverter *ic); | |||
bool FetchRecord(Barry::DBData &data, const Barry::IConverter *ic); | bool FetchRecord(Barry::DBData &data, const Barry::IConverter *ic); | |||
End of changes. 5 change blocks. | ||||
2 lines changed or deleted | 20 lines changed or added | |||
router.h | router.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file router.h | /// \file router.h | |||
/// Support classes for the pluggable socket routing system. | /// Support classes for the pluggable socket routing system. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 132 | skipping to change at line 132 | |||
// then set to false in the destructor | // then set to false in the destructor | |||
// to signal the end of the thread | // to signal the end of the thread | |||
// and handle the join | // and handle the join | |||
protected: | protected: | |||
// Provides a method of returning a buffer to the free queue | // Provides a method of returning a buffer to the free queue | |||
// after processing. The DataHandle class calls this automatically | // after processing. The DataHandle class calls this automatically | |||
// from its destructor. | // from its destructor. | |||
void ReturnBuffer(Data *buf); | void ReturnBuffer(Data *buf); | |||
// Helper function to add a buffer to a socket queue | ||||
// Returns false if no queue is available for that socket | ||||
// Also empties the DataHandle on success. | ||||
bool QueuePacket(SocketId socket, DataHandle &buf); | ||||
bool QueuePacket(DataQueue &queue, DataHandle &buf); | ||||
bool RouteOrQueuePacket(SocketId socket, DataHandle &buf); | ||||
// Thread function for the simple read behaviour... thread is | // Thread function for the simple read behaviour... thread is | |||
// created in the SpinoffSimpleReadThread() member below. | // created in the SpinoffSimpleReadThread() member below. | |||
static void *SimpleReadThread(void *userptr); | static void *SimpleReadThread(void *userptr); | |||
void DumpSocketQueue(SocketId socket, const DataQueue &dq); | ||||
public: | public: | |||
SocketRoutingQueue(int prealloc_buffer_count = 4, | SocketRoutingQueue(int prealloc_buffer_count = 4, | |||
int default_read_timeout = USBWRAP_DEFAULT_TIMEOUT); | int default_read_timeout = USBWRAP_DEFAULT_TIMEOUT); | |||
~SocketRoutingQueue(); | ~SocketRoutingQueue(); | |||
// | // | |||
// data access | // data access | |||
// | // | |||
int GetWriteEp() const { return m_writeEp; } | int GetWriteEp() const { return m_writeEp; } | |||
int GetReadEp() const { return m_readEp; } | int GetReadEp() const { return m_readEp; } | |||
skipping to change at line 277 | skipping to change at line 286 | |||
~DataHandle() | ~DataHandle() | |||
{ | { | |||
clear(); | clear(); | |||
} | } | |||
Data* get() | Data* get() | |||
{ | { | |||
return m_data; | return m_data; | |||
} | } | |||
Data* release() // no longer owns the pointer | Data* release() // no longer owns the pointer, and does not free it | |||
{ | { | |||
Data *ret = m_data; | Data *ret = m_data; | |||
m_data = 0; | m_data = 0; | |||
return ret; | return ret; | |||
} | } | |||
// frees current pointer, and takes ownership of new one | ||||
void reset(Data *next = 0) | ||||
{ | ||||
clear(); | ||||
m_data = next; | ||||
} | ||||
Data* operator->() | Data* operator->() | |||
{ | { | |||
return m_data; | return m_data; | |||
} | } | |||
const Data* operator->() const | const Data* operator->() const | |||
{ | { | |||
return m_data; | return m_data; | |||
} | } | |||
End of changes. 5 change blocks. | ||||
2 lines changed or deleted | 18 lines changed or added | |||
s11n-boost.h | s11n-boost.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file s11n-boost.h | /// \file s11n-boost.h | |||
/// Non-intrusive versions of serialization functions for the | /// Non-intrusive versions of serialization functions for the | |||
/// record classes. These template functions make it possible | /// record classes. These template functions make it possible | |||
/// to use the record classes with the Boost::Serialization | /// to use the record classes with the Boost::Serialization | |||
/// library. | /// library. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 50 | skipping to change at line 50 | |||
// POD data is included in the serialization | // POD data is included in the serialization | |||
// | // | |||
#define BARRY_BASE_S11N_VERSION 0 | #define BARRY_BASE_S11N_VERSION 0 | |||
#define BARRY_POD_MAP_VERSION 1000 | #define BARRY_POD_MAP_VERSION 1000 | |||
// namespace boost::serialization, for the non-intrusive version | // namespace boost::serialization, for the non-intrusive version | |||
namespace boost { | namespace boost { | |||
namespace serialization { | namespace serialization { | |||
template <class ArchiveT> | template <class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::TimeT &t, const unsigned int ver) | ||||
{ | ||||
ar & make_nvp("Barry::TimeT::Time", t.Time); | ||||
} | ||||
template <class ArchiveT> | ||||
void serialize(ArchiveT &ar, Barry::UnknownField &uf, const unsigned int ve r) | void serialize(ArchiveT &ar, Barry::UnknownField &uf, const unsigned int ve r) | |||
{ | { | |||
ar & make_nvp("type", uf.type); | ar & make_nvp("type", uf.type); | |||
ar & make_nvp("data", uf.data.raw_data); | ar & make_nvp("data", uf.data.raw_data); | |||
} | } | |||
template <class ArchiveT> | template <class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::Contact::GroupLink &g, const unsigned i nt ver) | void serialize(ArchiveT &ar, Barry::Contact::GroupLink &g, const unsigned i nt ver) | |||
{ | { | |||
ar & make_nvp("Link", g.Link); | ar & make_nvp("Link", g.Link); | |||
skipping to change at line 71 | skipping to change at line 77 | |||
} | } | |||
template <class ArchiveT> | template <class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::CategoryList &cl, const unsigned int ve r) | void serialize(ArchiveT &ar, Barry::CategoryList &cl, const unsigned int ve r) | |||
{ | { | |||
std::vector<std::string> &sl = cl; | std::vector<std::string> &sl = cl; | |||
ar & make_nvp("CategoryList", sl); | ar & make_nvp("CategoryList", sl); | |||
} | } | |||
template <class ArchiveT> | template <class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::EmailList &el, const unsigned int ver) | ||||
{ | ||||
std::vector<std::string> &sl = el; | ||||
ar & make_nvp("EmailList", sl); | ||||
} | ||||
template <class ArchiveT> | ||||
void serialize(ArchiveT &ar, Barry::Contact &c, const unsigned int ver) | void serialize(ArchiveT &ar, Barry::Contact &c, const unsigned int ver) | |||
{ | { | |||
ar & make_nvp("RecType", c.RecType); | ar & make_nvp("RecType", c.RecType); | |||
ar & make_nvp("RecordId", c.RecordId); | ar & make_nvp("RecordId", c.RecordId); | |||
ar & make_nvp("EmailAddresses", c.EmailAddresses); | ar & make_nvp("EmailAddresses", c.EmailAddresses); | |||
ar & make_nvp("Phone", c.Phone); | ar & make_nvp("Phone", c.Phone); | |||
ar & make_nvp("Fax", c.Fax); | ar & make_nvp("Fax", c.Fax); | |||
ar & make_nvp("HomeFax", c.HomeFax); | ar & make_nvp("HomeFax", c.HomeFax); | |||
ar & make_nvp("WorkPhone", c.WorkPhone); | ar & make_nvp("WorkPhone", c.WorkPhone); | |||
skipping to change at line 135 | skipping to change at line 148 | |||
} | } | |||
template <class ArchiveT> | template <class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::EmailAddress &a, const unsigned int ver ) | void serialize(ArchiveT &ar, Barry::EmailAddress &a, const unsigned int ver ) | |||
{ | { | |||
ar & make_nvp("Name", a.Name); | ar & make_nvp("Name", a.Name); | |||
ar & make_nvp("Email", a.Email); | ar & make_nvp("Email", a.Email); | |||
} | } | |||
template <class ArchiveT> | template <class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::EmailAddressList &eal, const unsigned i | ||||
nt ver) | ||||
{ | ||||
std::vector<Barry::EmailAddress> &v = eal; | ||||
ar & make_nvp("EmailAddressList", v); | ||||
} | ||||
template <class ArchiveT> | ||||
void serialize(ArchiveT &ar, Barry::Message &m, const unsigned int ver) | void serialize(ArchiveT &ar, Barry::Message &m, const unsigned int ver) | |||
{ | { | |||
ar & make_nvp("From", m.From); | ar & make_nvp("From", m.From); | |||
ar & make_nvp("To", m.To); | ar & make_nvp("To", m.To); | |||
ar & make_nvp("Cc", m.Cc); | ar & make_nvp("Cc", m.Cc); | |||
ar & make_nvp("Sender", m.Sender); | ar & make_nvp("Sender", m.Sender); | |||
ar & make_nvp("ReplyTo", m.ReplyTo); | ar & make_nvp("ReplyTo", m.ReplyTo); | |||
ar & make_nvp("Subject", m.Subject); | ar & make_nvp("Subject", m.Subject); | |||
ar & make_nvp("Body", m.Body); | ar & make_nvp("Body", m.Body); | |||
ar & make_nvp("Attachment", m.Attachment); | ar & make_nvp("Attachment", m.Attachment); | |||
ar & make_nvp("MessageRecordId", m.MessageRecordId); | ar & make_nvp("MessageRecordId", m.MessageRecordId); | |||
ar & make_nvp("MessageReplyTo", m.MessageReplyTo); | ar & make_nvp("MessageReplyTo", m.MessageReplyTo); | |||
ar & make_nvp("MessageDateSent", m.MessageDateSent); | ar & make_nvp("MessageDateSent", m.MessageDateSent.Time); | |||
ar & make_nvp("MessageDateReceived", m.MessageDateReceived); | ar & make_nvp("MessageDateReceived", m.MessageDateReceived.Time); | |||
ar & make_nvp("MessageTruncated", m.MessageTruncated); | ar & make_nvp("MessageTruncated", m.MessageTruncated); | |||
ar & make_nvp("MessageRead", m.MessageRead); | ar & make_nvp("MessageRead", m.MessageRead); | |||
ar & make_nvp("MessageReply", m.MessageReply); | ar & make_nvp("MessageReply", m.MessageReply); | |||
ar & make_nvp("MessageSaved", m.MessageSaved); | ar & make_nvp("MessageSaved", m.MessageSaved); | |||
ar & make_nvp("MessageSavedDeleted", m.MessageSavedDeleted); | ar & make_nvp("MessageSavedDeleted", m.MessageSavedDeleted); | |||
ar & make_nvp("MessagePriority", m.Priority); | ar & make_nvp("MessagePriority", m.Priority); | |||
ar & make_nvp("MessageSensitivity", m.Sensitivity); | ar & make_nvp("MessageSensitivity", m.Sensitivity); | |||
skipping to change at line 176 | skipping to change at line 196 | |||
{ | { | |||
ar & make_nvp("RecType", c.RecType); | ar & make_nvp("RecType", c.RecType); | |||
ar & make_nvp("RecordId", c.RecordId); | ar & make_nvp("RecordId", c.RecordId); | |||
ar & make_nvp("AllDayEvent", c.AllDayEvent); | ar & make_nvp("AllDayEvent", c.AllDayEvent); | |||
ar & make_nvp("Subject", c.Subject); | ar & make_nvp("Subject", c.Subject); | |||
ar & make_nvp("Notes", c.Notes); | ar & make_nvp("Notes", c.Notes); | |||
ar & make_nvp("Location", c.Location); | ar & make_nvp("Location", c.Location); | |||
ar & make_nvp("NotificationTime", c.NotificationTime); | ar & make_nvp("NotificationTime", c.NotificationTime.Time); | |||
ar & make_nvp("StartTime", c.StartTime); | ar & make_nvp("StartTime", c.StartTime.Time); | |||
ar & make_nvp("EndTime", c.EndTime); | ar & make_nvp("EndTime", c.EndTime.Time); | |||
ar & make_nvp("Organizer", c.Organizer); | ar & make_nvp("Organizer", c.Organizer); | |||
ar & make_nvp("AcceptedBy", c.AcceptedBy); | ar & make_nvp("AcceptedBy", c.AcceptedBy); | |||
ar & make_nvp("Invited", c.Invited); | ar & make_nvp("Invited", c.Invited); | |||
ar & make_nvp("FreeBusyFlag", c.FreeBusyFlag); | ar & make_nvp("FreeBusyFlag", c.FreeBusyFlag); | |||
ar & make_nvp("ClassFlag", c.ClassFlag); | ar & make_nvp("ClassFlag", c.ClassFlag); | |||
ar & make_nvp("Recurring", c.Recurring); | ar & make_nvp("Recurring", c.Recurring); | |||
ar & make_nvp("RecurringType", c.RecurringType); | ar & make_nvp("RecurringType", c.RecurringType); | |||
ar & make_nvp("Interval", c.Interval); | ar & make_nvp("Interval", c.Interval); | |||
ar & make_nvp("RecurringEndTime", c.RecurringEndTime); | ar & make_nvp("RecurringEndTime", c.RecurringEndTime.Time); | |||
ar & make_nvp("Perpetual", c.Perpetual); | ar & make_nvp("Perpetual", c.Perpetual); | |||
ar & make_nvp("CalendarID", c.CalendarID); | ar & make_nvp("CalendarID", c.CalendarID); | |||
ar & make_nvp("TimeZoneCode", c.TimeZoneCode); | ar & make_nvp("TimeZoneCode", c.TimeZoneCode); | |||
ar & make_nvp("TimeZoneValid", c.TimeZoneValid); | ar & make_nvp("TimeZoneValid", c.TimeZoneValid); | |||
ar & make_nvp("DayOfWeek", c.DayOfWeek); | ar & make_nvp("DayOfWeek", c.DayOfWeek); | |||
ar & make_nvp("WeekOfMonth", c.WeekOfMonth); | ar & make_nvp("WeekOfMonth", c.WeekOfMonth); | |||
ar & make_nvp("DayOfMonth", c.DayOfMonth); | ar & make_nvp("DayOfMonth", c.DayOfMonth); | |||
ar & make_nvp("MonthOfYear", c.MonthOfYear); | ar & make_nvp("MonthOfYear", c.MonthOfYear); | |||
ar & make_nvp("WeekDays", c.WeekDays); | ar & make_nvp("WeekDays", c.WeekDays); | |||
skipping to change at line 312 | skipping to change at line 332 | |||
void serialize(ArchiveT &ar, Barry::Task &t, const unsigned int ver) | void serialize(ArchiveT &ar, Barry::Task &t, const unsigned int ver) | |||
{ | { | |||
ar & make_nvp("RecType", t.RecType); | ar & make_nvp("RecType", t.RecType); | |||
ar & make_nvp("RecordId", t.RecordId); | ar & make_nvp("RecordId", t.RecordId); | |||
ar & make_nvp("Summary", t.Summary); | ar & make_nvp("Summary", t.Summary); | |||
ar & make_nvp("Notes", t.Notes); | ar & make_nvp("Notes", t.Notes); | |||
ar & make_nvp("Categories", t.Categories); | ar & make_nvp("Categories", t.Categories); | |||
ar & make_nvp("UID", t.UID); | ar & make_nvp("UID", t.UID); | |||
ar & make_nvp("StartTime", t.StartTime); | ar & make_nvp("StartTime", t.StartTime.Time); | |||
ar & make_nvp("DueTime", t.DueTime); | ar & make_nvp("DueTime", t.DueTime.Time); | |||
ar & make_nvp("AlarmTime", t.AlarmTime); | ar & make_nvp("AlarmTime", t.AlarmTime.Time); | |||
ar & make_nvp("TimeZoneCode", t.TimeZoneCode); | ar & make_nvp("TimeZoneCode", t.TimeZoneCode); | |||
ar & make_nvp("TimeZoneValid", t.TimeZoneValid); | ar & make_nvp("TimeZoneValid", t.TimeZoneValid); | |||
ar & make_nvp("AlarmType", t.AlarmType); | ar & make_nvp("AlarmType", t.AlarmType); | |||
ar & make_nvp("Interval", t.Interval); | ar & make_nvp("Interval", t.Interval); | |||
ar & make_nvp("RecurringType", t.RecurringType); | ar & make_nvp("RecurringType", t.RecurringType); | |||
ar & make_nvp("RecurringEndTime", t.RecurringEndTime); | ar & make_nvp("RecurringEndTime", t.RecurringEndTime.Time); | |||
ar & make_nvp("DayOfWeek", t.DayOfWeek); | ar & make_nvp("DayOfWeek", t.DayOfWeek); | |||
ar & make_nvp("WeekOfMonth", t.WeekOfMonth); | ar & make_nvp("WeekOfMonth", t.WeekOfMonth); | |||
ar & make_nvp("DayOfMonth", t.DayOfMonth); | ar & make_nvp("DayOfMonth", t.DayOfMonth); | |||
ar & make_nvp("MonthOfYear", t.MonthOfYear); | ar & make_nvp("MonthOfYear", t.MonthOfYear); | |||
ar & make_nvp("WeekDays", t.WeekDays); | ar & make_nvp("WeekDays", t.WeekDays); | |||
ar & make_nvp("PriorityFlag", t.PriorityFlag); | ar & make_nvp("PriorityFlag", t.PriorityFlag); | |||
ar & make_nvp("StatusFlag", t.StatusFlag); | ar & make_nvp("StatusFlag", t.StatusFlag); | |||
ar & make_nvp("Recurring", t.Recurring); | ar & make_nvp("Recurring", t.Recurring); | |||
ar & make_nvp("Perpetual", t.Perpetual); | ar & make_nvp("Perpetual", t.Perpetual); | |||
ar & make_nvp("DueDateFlag", t.DueDateFlag); | ||||
if( ver < BARRY_POD_MAP_VERSION ) { | if( ver < BARRY_POD_MAP_VERSION ) { | |||
ar & make_nvp( "Unknowns", t.Unknowns); | ar & make_nvp( "Unknowns", t.Unknowns); | |||
} | } | |||
} | } | |||
template<class ArchiveT> | template<class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::PINMessage &p, const unsigned int ver) | void serialize(ArchiveT &ar, Barry::PINMessage &p, const unsigned int ver) | |||
{ | { | |||
ar & make_nvp("RecType", p.RecType); | ar & make_nvp("RecType", p.RecType); | |||
ar & make_nvp("RecordId", p.RecordId); | ar & make_nvp("RecordId", p.RecordId); | |||
ar & make_nvp("From", p.From); | ar & make_nvp("From", p.From); | |||
ar & make_nvp("To", p.To); | ar & make_nvp("To", p.To); | |||
ar & make_nvp("Cc", p.Cc); | ar & make_nvp("Cc", p.Cc); | |||
ar & make_nvp("Bcc", p.Bcc); | ar & make_nvp("Bcc", p.Bcc); | |||
ar & make_nvp("Subject", p.Subject); | ar & make_nvp("Subject", p.Subject); | |||
ar & make_nvp("Body", p.Body); | ar & make_nvp("Body", p.Body); | |||
ar & make_nvp("MessageRecordId", p.MessageRecordId); | ar & make_nvp("MessageRecordId", p.MessageRecordId); | |||
ar & make_nvp("MessageReplyTo", p.MessageReplyTo); | ar & make_nvp("MessageReplyTo", p.MessageReplyTo); | |||
ar & make_nvp("MessageDateSent", p.MessageDateSent); | ar & make_nvp("MessageDateSent", p.MessageDateSent.Time); | |||
ar & make_nvp("MessageDateReceived", p.MessageDateReceived); | ar & make_nvp("MessageDateReceived", p.MessageDateReceived.Time); | |||
ar & make_nvp("MessageTruncated", p.MessageTruncated); | ar & make_nvp("MessageTruncated", p.MessageTruncated); | |||
ar & make_nvp("MessageRead", p.MessageRead); | ar & make_nvp("MessageRead", p.MessageRead); | |||
ar & make_nvp("MessageReply", p.MessageReply); | ar & make_nvp("MessageReply", p.MessageReply); | |||
ar & make_nvp("MessageSaved", p.MessageSaved); | ar & make_nvp("MessageSaved", p.MessageSaved); | |||
ar & make_nvp("MessageSavedDeleted", p.MessageSavedDeleted); | ar & make_nvp("MessageSavedDeleted", p.MessageSavedDeleted); | |||
ar & make_nvp("MessagePriority", p.Priority); | ar & make_nvp("MessagePriority", p.Priority); | |||
ar & make_nvp("MessageSensitivity", p.Sensitivity); | ar & make_nvp("MessageSensitivity", p.Sensitivity); | |||
skipping to change at line 388 | skipping to change at line 407 | |||
ar & make_nvp("To", m.To); | ar & make_nvp("To", m.To); | |||
ar & make_nvp("Cc", m.Cc); | ar & make_nvp("Cc", m.Cc); | |||
ar & make_nvp("Bcc", m.Bcc); | ar & make_nvp("Bcc", m.Bcc); | |||
ar & make_nvp("Sender", m.Sender); | ar & make_nvp("Sender", m.Sender); | |||
ar & make_nvp("ReplyTo", m.ReplyTo); | ar & make_nvp("ReplyTo", m.ReplyTo); | |||
ar & make_nvp("Subject", m.Subject); | ar & make_nvp("Subject", m.Subject); | |||
ar & make_nvp("Body", m.Body); | ar & make_nvp("Body", m.Body); | |||
ar & make_nvp("Attachment", m.Attachment); | ar & make_nvp("Attachment", m.Attachment); | |||
ar & make_nvp("MessageRecordId", m.MessageRecordId); | ar & make_nvp("MessageRecordId", m.MessageRecordId); | |||
ar & make_nvp("MessageReplyTo", m.MessageReplyTo); | ar & make_nvp("MessageReplyTo", m.MessageReplyTo); | |||
ar & make_nvp("MessageDateSent", m.MessageDateSent); | ar & make_nvp("MessageDateSent", m.MessageDateSent.Time); | |||
ar & make_nvp("MessageDateReceived", m.MessageDateReceived); | ar & make_nvp("MessageDateReceived", m.MessageDateReceived.Time); | |||
ar & make_nvp("MessageTruncated", m.MessageTruncated); | ar & make_nvp("MessageTruncated", m.MessageTruncated); | |||
ar & make_nvp("MessageRead", m.MessageRead); | ar & make_nvp("MessageRead", m.MessageRead); | |||
ar & make_nvp("MessageReply", m.MessageReply); | ar & make_nvp("MessageReply", m.MessageReply); | |||
ar & make_nvp("MessageSaved", m.MessageSaved); | ar & make_nvp("MessageSaved", m.MessageSaved); | |||
ar & make_nvp("MessageSavedDeleted", m.MessageSavedDeleted); | ar & make_nvp("MessageSavedDeleted", m.MessageSavedDeleted); | |||
ar & make_nvp("MessagePriority", m.Priority); | ar & make_nvp("MessagePriority", m.Priority); | |||
ar & make_nvp("MessageSensitivity", m.Sensitivity); | ar & make_nvp("MessageSensitivity", m.Sensitivity); | |||
skipping to change at line 451 | skipping to change at line 470 | |||
ar & make_nvp("FolderNumber", f.Number); | ar & make_nvp("FolderNumber", f.Number); | |||
ar & make_nvp("FolderLevel", f.Level); | ar & make_nvp("FolderLevel", f.Level); | |||
ar & make_nvp("FolderType", f.Type); | ar & make_nvp("FolderType", f.Type); | |||
if( ver < BARRY_POD_MAP_VERSION ) { | if( ver < BARRY_POD_MAP_VERSION ) { | |||
ar & make_nvp( "Unknowns", f.Unknowns); | ar & make_nvp( "Unknowns", f.Unknowns); | |||
} | } | |||
} | } | |||
template <class ArchiveT> | template <class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::Timezone &t, const unsigned int ver) | void serialize(ArchiveT &ar, Barry::TimeZone &t, const unsigned int ver) | |||
{ | { | |||
ar & make_nvp("RecType", t.RecType); | ar & make_nvp("RecType", t.RecType); | |||
ar & make_nvp("RecordId", t.RecordId); | ar & make_nvp("RecordId", t.RecordId); | |||
ar & make_nvp("TZType", t.TZType); | ar & make_nvp("Name", t.Name); | |||
ar & make_nvp("DSTOffset", t.DSTOffset); | ||||
ar & make_nvp("Index", t.Index); | ar & make_nvp("Index", t.Index); | |||
ar & make_nvp("Offset", t.Offset); | ar & make_nvp("UTCOffset", t.UTCOffset); | |||
ar & make_nvp("OffsetFraction", t.OffsetFraction); | ||||
ar & make_nvp("UseDST", t.UseDST); | ||||
ar & make_nvp("DSTOffset", t.DSTOffset); | ||||
ar & make_nvp("StartMonth", t.StartMonth); | ar & make_nvp("StartMonth", t.StartMonth); | |||
ar & make_nvp("EndMonth", t.EndMonth); | ar & make_nvp("EndMonth", t.EndMonth); | |||
ar & make_nvp("Left", t.Left); | ||||
ar & make_nvp("UseDST", t.UseDST); | ||||
ar & make_nvp("TimeZoneName", t.TimeZoneName); | ar & make_nvp("TZType", t.TZType); | |||
if( ver < BARRY_POD_MAP_VERSION ) { | if( ver < BARRY_POD_MAP_VERSION ) { | |||
ar & make_nvp("Unknowns", t.Unknowns); | ar & make_nvp("Unknowns", t.Unknowns); | |||
} | } | |||
} | } | |||
template <class ArchiveT> | template <class ArchiveT> | |||
void serialize(ArchiveT &ar, Barry::ContentStore &c, const unsigned int ver ) | void serialize(ArchiveT &ar, Barry::ContentStore &c, const unsigned int ver ) | |||
{ | { | |||
ar & make_nvp("RecType", c.RecType); | ar & make_nvp("RecType", c.RecType); | |||
skipping to change at line 491 | skipping to change at line 509 | |||
ar & make_nvp("FileContent", c.FileContent); | ar & make_nvp("FileContent", c.FileContent); | |||
ar & make_nvp("FileDescriptor", c.FileDescriptor); | ar & make_nvp("FileDescriptor", c.FileDescriptor); | |||
// FileSize is not used for building, so no need to save it here | // FileSize is not used for building, so no need to save it here | |||
if( ver < BARRY_POD_MAP_VERSION ) { | if( ver < BARRY_POD_MAP_VERSION ) { | |||
ar & make_nvp("Unknowns", c.Unknowns); | ar & make_nvp("Unknowns", c.Unknowns); | |||
} | } | |||
} | } | |||
template <class ArchiveT> | ||||
void serialize(ArchiveT &ar, Barry::HandheldAgent &h, const unsigned int ve | ||||
r) | ||||
{ | ||||
ar & make_nvp("RecType", h.RecType); | ||||
ar & make_nvp("RecordId", h.RecordId); | ||||
ar & make_nvp("MEID", h.MEID); | ||||
ar & make_nvp("Model", h.Model); | ||||
ar & make_nvp("Bands", h.Bands); | ||||
ar & make_nvp("Pin", h.Pin); | ||||
ar & make_nvp("Version", h.Version); | ||||
ar & make_nvp("PlatformVersion", h.PlatformVersion); | ||||
ar & make_nvp("Manufacturer", h.Manufacturer); | ||||
ar & make_nvp("Network", h.Network); | ||||
if( ver < BARRY_POD_MAP_VERSION ) { | ||||
ar & make_nvp("Unknowns", h.Unknowns); | ||||
} | ||||
} | ||||
}} // namespace boost::serialization | }} // namespace boost::serialization | |||
/////////////////////////////////////////////////////////////////////////// /// | /////////////////////////////////////////////////////////////////////////// /// | |||
// Helper wrapper templates for loading and saving records to an iostream | // Helper wrapper templates for loading and saving records to an iostream | |||
namespace Barry { | namespace Barry { | |||
// Can be used as a Storage class for RecordBuilder<> | // Can be used as a Storage class for RecordBuilder<> | |||
template <class RecordT> | template <class RecordT> | |||
class BoostLoader | class BoostLoader | |||
End of changes. 18 change blocks. | ||||
24 lines changed or deleted | 64 lines changed or added | |||
scoped_lock.h | scoped_lock.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file scoped_lock.h | /// \file scoped_lock.h | |||
/// Simple scope class for dealing with pthread mutex locking. | /// Simple scope class for dealing with pthread mutex locking. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2008-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
socket.h | socket.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file socket.h | /// \file socket.h | |||
/// Class wrapper to encapsulate the Blackberry USB logical sock et | /// Class wrapper to encapsulate the Blackberry USB logical sock et | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 30 | skipping to change at line 30 | |||
*/ | */ | |||
#ifndef __BARRY_SOCKET_H__ | #ifndef __BARRY_SOCKET_H__ | |||
#define __BARRY_SOCKET_H__ | #define __BARRY_SOCKET_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include <stdint.h> | #include <stdint.h> | |||
#include <queue> | #include <queue> | |||
#include <memory> | #include <memory> | |||
#include "router.h" | #include "router.h" | |||
#include "data.h" | ||||
// forward declarations | // forward declarations | |||
namespace Usb { class Device; } | namespace Usb { class Device; } | |||
namespace Barry { | namespace Barry { | |||
class Data; | ||||
class Packet; | class Packet; | |||
class JLPacket; | class JLPacket; | |||
class JVMPacket; | class JVMPacket; | |||
class SocketRoutingQueue; | class SocketRoutingQueue; | |||
} | } | |||
namespace Barry { | namespace Barry { | |||
class SocketBase; | ||||
class Socket; | class Socket; | |||
typedef std::auto_ptr<Socket> SocketHandle; | typedef std::auto_ptr<SocketBase> SocketHandle; | |||
class BXEXPORT SocketZero | class BXEXPORT SocketZero | |||
{ | { | |||
friend class SocketBase; | ||||
friend class Socket; | friend class Socket; | |||
Usb::Device *m_dev; | Usb::Device *m_dev; | |||
SocketRoutingQueue *m_queue; | SocketRoutingQueue *m_queue; | |||
int m_writeEp, m_readEp; | int m_writeEp, m_readEp; | |||
uint8_t m_zeroSocketSequence; | uint8_t m_zeroSocketSequence; | |||
uint32_t m_sequenceId; | uint32_t m_sequenceId; | |||
// half open socket stata, for passwords | // half open socket stata, for passwords | |||
bool m_halfOpen; | bool m_halfOpen; | |||
uint32_t m_challengeSeed; | uint32_t m_challengeSeed; | |||
unsigned int m_remainingTries; | unsigned int m_remainingTries; | |||
bool m_modeSequencePacketSeen; | ||||
bool m_hideSequencePacket; | // pushback for out of order sequence packets | |||
Data m_pushback_buffer; | ||||
bool m_resetOnClose; | bool m_pushback; | |||
private: | private: | |||
static void AppendFragment(Data &whole, const Data &fragment); | static void AppendFragment(Data &whole, const Data &fragment); | |||
static unsigned int MakeNextFragment(const Data &whole, Data &fragme nt, | static unsigned int MakeNextFragment(const Data &whole, Data &fragme nt, | |||
unsigned int offset = 0); | unsigned int offset = 0); | |||
void CheckSequence(uint16_t socket, const Data &seq); | void CheckSequence(uint16_t socket, const Data &seq); | |||
void SendOpen(uint16_t socket, Data &receive); | void SendOpen(uint16_t socket, Data &receive); | |||
void SendPasswordHash(uint16_t socket, const char *password, Data &r eceive); | void SendPasswordHash(uint16_t socket, const char *password, Data &r eceive); | |||
// Raw send and receive functions, used for all low level | // Raw send and receive functions, used for all low level | |||
// communication to the USB level. | // communication to the USB level. | |||
void RawSend(Data &send, int timeout = -1); | void RawSend(Data &send, int timeout = -1); | |||
void RawReceive(Data &receive, int timeout = -1); | void RawReceive(Data &receive, int timeout = -1); | |||
void Pushback(const Data &buf); | ||||
protected: | protected: | |||
bool SequencePacket(const Data &data); | bool IsSequencePacketHidden() { return false; } | |||
bool IsSequencePacketHidden() { return m_hideSequencePacket; } | ||||
public: | public: | |||
explicit SocketZero(SocketRoutingQueue &queue, int writeEndpoint, | explicit SocketZero(SocketRoutingQueue &queue, int writeEndpoint, | |||
uint8_t zeroSocketSequenceStart = 0); | uint8_t zeroSocketSequenceStart = 0); | |||
SocketZero(Usb::Device &dev, int writeEndpoint, int readEndpoint, | SocketZero(Usb::Device &dev, int writeEndpoint, int readEndpoint, | |||
uint8_t zeroSocketSequenceStart = 0); | uint8_t zeroSocketSequenceStart = 0); | |||
~SocketZero(); | ~SocketZero(); | |||
uint8_t GetZeroSocketSequence() const { return m_zeroSocketSequence; } | uint8_t GetZeroSocketSequence() const { return m_zeroSocketSequence; } | |||
void SetRoutingQueue(SocketRoutingQueue &queue); | void SetRoutingQueue(SocketRoutingQueue &queue); | |||
void UnlinkRoutingQueue(); | void UnlinkRoutingQueue(); | |||
void SetResetOnClose(bool flag) { m_resetOnClose = flag; } | ||||
void HideSequencePacket(bool flag) { m_hideSequencePacket = flag; } | ||||
// Send functions for socket 0 only. | // Send functions for socket 0 only. | |||
// These functions will overwrite: | // These functions will overwrite: | |||
// - the zeroSocketSequence byte *inside* the packet | // - the zeroSocketSequence byte *inside* the packet | |||
// - the socket number to 0 | // - the socket number to 0 | |||
// | // | |||
void Send(Data &send, int timeout = -1); // send only | void Send(Data &send, int timeout = -1); // send only | |||
void Send(Data &send, Data &receive, int timeout = -1); // send+recv | void Send(Data &send, Data &receive, int timeout = -1); // send+recv | |||
void Send(Barry::Packet &packet, int timeout = -1); | void Send(Barry::Packet &packet, int timeout = -1); | |||
void Receive(Data &receive, int timeout = -1); | void Receive(Data &receive, int timeout = -1); | |||
// Opens a new socket and returns a Socket object to manage it | // Opens a new socket and returns a Socket object to manage it | |||
SocketHandle Open(uint16_t socket, const char *password = 0); | SocketHandle Open(uint16_t socket, const char *password = 0); | |||
void Close(Socket &socket); | void Close(Socket &socket); | |||
}; | ||||
// Lower level USB operations | class BXEXPORT SocketBase | |||
void ClearHalt(); | { | |||
bool m_resetOnClose; | ||||
protected: | ||||
void CheckSequence(const Data &seq); | ||||
public: | ||||
SocketBase() | ||||
: m_resetOnClose(false) | ||||
{ | ||||
} | ||||
virtual ~SocketBase(); | ||||
// | ||||
// Virtual Socket API | ||||
// | ||||
virtual void Close() = 0; | ||||
// FIXME - do I need RawSend? Or just a good fragmenter? | ||||
virtual void RawSend(Data &send, int timeout = -1) = 0; | ||||
virtual void SyncSend(Data &send, int timeout = -1) = 0; | ||||
virtual void Receive(Data &receive, int timeout = -1) = 0; | ||||
virtual void RegisterInterest(Barry::SocketRoutingQueue::SocketDataH | ||||
andlerPtr handler = Barry::SocketRoutingQueue::SocketDataHandlerPtr()) = 0; | ||||
virtual void UnregisterInterest() = 0; | ||||
void ResetOnClose(bool reset = true) { m_resetOnClose = reset; } | ||||
bool IsResetOnClose() const { return m_resetOnClose; } | ||||
// | ||||
// Convenience functions that just call the virtuals above | ||||
// | ||||
void DBFragSend(Data &send, int timeout = -1); | ||||
void Send(Data &send, Data &receive, int timeout = -1); | ||||
void Send(Barry::Packet &packet, int timeout = -1); | ||||
// | ||||
// Protocol based functions... all use the above virtual functions | ||||
// | ||||
// sends the send packet down to the device, fragmenting if | ||||
// necessary, and returns the response in receive, defragmenting | ||||
// if needed | ||||
// Blocks until response received or timed out in Usb::Device | ||||
void Packet(Data &send, Data &receive, int timeout = -1); | ||||
void Packet(Barry::Packet &packet, int timeout = -1); | ||||
void Packet(Barry::JLPacket &packet, int timeout = -1); | ||||
void Packet(Barry::JVMPacket &packet, int timeout = -1); | ||||
// Use this function to send packet to JVM instead of Packet functio | ||||
n | ||||
// FIXME | ||||
void PacketJVM(Data &send, Data &receive, int timeout = -1); | ||||
// Use this function to send data packet instead of Packet function | ||||
// Indeed, Packet function is used to send command (and not data) | ||||
// FIXME | ||||
void PacketData(Data &send, Data &receive, bool done_on_sequence, | ||||
int timeout = -1); | ||||
// some handy wrappers for the Packet() interface | ||||
void NextRecord(Data &receive); | ||||
}; | }; | |||
// | // | |||
// Socket class | // Socket class | |||
// | // | |||
/// Encapsulates a "logical socket" in the Blackberry USB protocol. | /// Encapsulates a "logical socket" in the Blackberry USB protocol. | |||
/// By default, provides raw send/receive access, as well as packet | /// By default, provides raw send/receive access, as well as packet | |||
/// writing on socket 0, which is always open. | /// writing on socket 0, which is always open. | |||
/// | /// | |||
/// There are Open and Close members to open data sockets which are used | /// There are Open and Close members to open data sockets which are used | |||
/// to transfer data to and from the device. | /// to transfer data to and from the device. | |||
/// | /// | |||
/// The destructor will close any non-0 open sockets automatically. | /// The destructor will close any non-0 open sockets automatically. | |||
/// | /// | |||
/// Requires an active Usb::Device object to work on. | /// Requires an active Usb::Device object to work on. | |||
/// | /// | |||
class BXEXPORT Socket | class BXEXPORT Socket : public SocketBase | |||
{ | { | |||
friend class SocketZero; | friend class SocketZero; | |||
SocketZero *m_zero; | SocketZero *m_zero; | |||
uint16_t m_socket; | uint16_t m_socket; | |||
uint8_t m_closeFlag; | uint8_t m_closeFlag; | |||
bool m_registered; | bool m_registered; | |||
// buffer data | ||||
std::auto_ptr<Data> m_sequence; | ||||
protected: | protected: | |||
void CheckSequence(const Data &seq); | ||||
void ForceClosed(); | void ForceClosed(); | |||
Socket(SocketZero &zero, uint16_t socket, uint8_t closeFlag); | // These "Local" function are non-virtual worker functions, | |||
// which are safe to be called from the destructor. | ||||
public: | // If you override the virtual versions in your derived class, | |||
~Socket(); | // make sure your "Local" versions call us. | |||
void LocalClose(); | ||||
void LocalUnregisterInterest(); | ||||
uint16_t GetSocket() const { return m_socket; } | uint16_t GetSocket() const { return m_socket; } | |||
uint8_t GetCloseFlag() const { return m_closeFlag; } | uint8_t GetCloseFlag() const { return m_closeFlag; } | |||
void Close(); | Socket(SocketZero &zero, uint16_t socket, uint8_t closeFlag); | |||
// Send and Receive are available before Open... | ||||
// an unopened socket defaults to socket 0, which you need | ||||
// in order to set the blackberry mode | ||||
// The send function will overwrite the zeroSocketSequence byte | ||||
// *inside* the packet, if the current m_socket is 0. | ||||
void Send(Data &send, int timeout = -1); // send only | ||||
void Send(Data &send, Data &receive, int timeout = -1); // send+recv | ||||
void Send(Barry::Packet &packet, int timeout = -1); | ||||
void Receive(Data &receive, int timeout = -1); | ||||
void ReceiveData(Data &receive, int timeout = -1); | ||||
// Lower level USB operations | ||||
void ClearHalt(); | ||||
// sends the send packet down to the device, fragmenting if | ||||
// necessary, and returns the response in receive, defragmenting | ||||
// if needed | ||||
// Blocks until response received or timed out in Usb::Device | ||||
void Packet(Data &send, Data &receive, int timeout = -1); | ||||
void Packet(Barry::Packet &packet, int timeout = -1); | ||||
void Packet(Barry::JLPacket &packet, int timeout = -1); | ||||
void Packet(Barry::JVMPacket &packet, int timeout = -1); | ||||
// Use this function to send packet to JVM instead of Packet functio | ||||
n | ||||
void InitSequence(int timeout = -1); | ||||
void PacketJVM(Data &send, Data &receive, int timeout = -1); | ||||
// Use this function to send data packet instead of Packet function | public: | |||
// Indeed, Packet function is used to send command (and not data) | ~Socket(); | |||
void PacketData(Data &send, Data &receive, int timeout = -1); | ||||
// some handy wrappers for the Packet() interface | // | |||
void NextRecord(Data &receive); | // virtual overrides | |||
// | ||||
void Close() { LocalClose(); } | ||||
void RawSend(Data &send, int timeout = -1); | ||||
void SyncSend(Data &send, int timeout = -1); | ||||
void Receive(Data &receive, int timeout = -1); | ||||
// Register a callback for incoming data from the device. | // Register a callback for incoming data from the device. | |||
// This function assumes that this socket is based on a socketZero | // This function assumes that this socket is based on a socketZero | |||
// that has a SocketRoutingQueue, otherwise throws logic_error. | // that has a SocketRoutingQueue, otherwise throws logic_error. | |||
void RegisterInterest(std::tr1::shared_ptr<SocketRoutingQueue::Socke | // It also assumes that nothing has been registered before. | |||
tDataHandler> handler); | // If you wish to re-register, call UnregisterInterest() first, | |||
void UnregisterInterest(); | // which is safe to call as many times as you like. | |||
void RegisterInterest(Barry::SocketRoutingQueue::SocketDataHandlerPt | ||||
// This function is quickly written | r handler = Barry::SocketRoutingQueue::SocketDataHandlerPtr()); | |||
// It's very durty :( (but it's usefull to test...) | void UnregisterInterest() { LocalUnregisterInterest(); } | |||
void HideSequencePacket(bool flag) { m_zero->HideSequencePacket(flag | ||||
); } | ||||
}; | }; | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 21 change blocks. | ||||
61 lines changed or deleted | 104 lines changed or added | |||
threadwrap.h | threadwrap.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
#ifndef __BARRY_THREADWRAP_H__ | #ifndef __BARRY_THREADWRAP_H__ | |||
#define __BARRY_THREADWRAP_H__ | #define __BARRY_THREADWRAP_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include <pthread.h> | #include <pthread.h> | |||
namespace Barry { | namespace Barry { | |||
class BXEXPORT Thread | class BXEXPORT Thread | |||
{ | { | |||
public: | ||||
struct CallbackData | ||||
{ | ||||
void *(*callback)(Barry::Thread::CallbackData *data); | ||||
// user-accessible data | ||||
volatile bool stopflag; | ||||
void *userdata; | ||||
explicit CallbackData(void *userdata); | ||||
}; | ||||
private: | private: | |||
pthread_t thread; | pthread_t thread; | |||
int m_socket; | ||||
CallbackData *m_data; | ||||
public: | public: | |||
Thread(int socket, void *(*callback)(void *data), void *data); | // Note: the data pointer passed into callback is not the same | |||
// as userdata. The data pointer is a pointer to CallbackData | ||||
// which will contain the userdata pointer. | ||||
Thread(int socket, | ||||
void *(*callback)(Barry::Thread::CallbackData *data), | ||||
void *userdata); | ||||
~Thread(); | ~Thread(); | |||
void Dispose(); | /// Sets stopflag in the callback data to true | |||
void StopFlag(); | ||||
}; | }; | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 22 lines changed or added | |||
time.h | time.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file time.h | /// \file time.h | |||
/// Time related conversion routines. | /// Time related conversion routines. | |||
/// time_t is the POSIX time. | /// time_t is the POSIX time. | |||
/// min1900_t is the minutes from Jan 1, 1900 | /// min1900_t is the minutes from Jan 1, 1900 | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 56 | skipping to change at line 56 | |||
// time in minutes: | // time in minutes: | |||
#define STDC_MIN1900_DIFF (YEAR_COUNT * YEAR_MINUTES + LEAP_YEAR_COUNT * DA Y_MINUTES) | #define STDC_MIN1900_DIFF (YEAR_COUNT * YEAR_MINUTES + LEAP_YEAR_COUNT * DA Y_MINUTES) | |||
namespace Barry { | namespace Barry { | |||
typedef long min1900_t; | typedef long min1900_t; | |||
BXEXPORT min1900_t time2min(time_t t); | BXEXPORT min1900_t time2min(time_t t); | |||
BXEXPORT time_t min2time(min1900_t m); | BXEXPORT time_t min2time(min1900_t m); | |||
// FIXME - turn TimeZone into a C typedef and wrap this in extern "C" | // FIXME - turn StaticTimeZone into a C typedef and wrap this in extern "C" | |||
// so the data can be used in both C and C++ libraries | // so the data can be used in both C and C++ libraries | |||
struct BXEXPORT TimeZone | // | |||
// This is named StaticTimeZone since the time zone table is hard coded | ||||
// in the library. If you want to know what the device's idea of time zone | ||||
s | ||||
// is, then extract the time zone database using the TimeZone record class. | ||||
// | ||||
// See also the TimeZones class, which unifies access to the static and | ||||
// dynamic time zone tables in one class API. | ||||
// | ||||
struct BXEXPORT StaticTimeZone | ||||
{ | { | |||
unsigned short Code; | uint16_t Code; | |||
signed short HourOffset; | signed short HourOffset; | |||
signed short MinOffset; | signed short MinOffset; | |||
const char *Name; | const char *Name; | |||
}; | }; | |||
// FIXME - put this somewhere for both C and C++ | // FIXME - put this somewhere for both C and C++ | |||
#define TIME_ZONE_CODE_ERR 0xffff | #define STATIC_TIME_ZONE_CODE_ERR 0xffff | |||
BXEXPORT const TimeZone* GetTimeZoneTable(); | BXEXPORT const StaticTimeZone* GetStaticTimeZoneTable(); | |||
BXEXPORT const TimeZone* GetTimeZone(unsigned short Code); | BXEXPORT const StaticTimeZone* GetStaticTimeZone(uint16_t Code); | |||
BXEXPORT unsigned short GetTimeZoneCode(signed short HourOffset, | BXEXPORT unsigned short GetStaticTimeZoneCode(signed short HourOffset, | |||
signed short MinOffset = 0); | signed short MinOffset = 0); | |||
// Message time conversion stuff | // Message time conversion stuff | |||
BXEXPORT time_t DayToDate( unsigned short Day ); | BXEXPORT time_t DayToDate( uint16_t Day ); | |||
BXEXPORT time_t Message2Time(uint16_t r_date, uint16_t r_time); | BXEXPORT time_t Message2Time(uint16_t r_date, uint16_t r_time); | |||
// Thread timeout creation | // Thread timeout creation | |||
BXEXPORT struct timespec* ThreadTimeout(int timeout_ms, struct timespec *sp ec); | BXEXPORT struct timespec* ThreadTimeout(int timeout_ms, struct timespec *sp ec); | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 7 change blocks. | ||||
9 lines changed or deleted | 18 lines changed or added | |||
tzwrapper.h | tzwrapper.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file tzwrapper.h | /// \file tzwrapper.h | |||
/// Timezone adjustment class, wrapping the TZ environment | /// Timezone adjustment class, wrapping the TZ environment | |||
/// variable to make struct tm -> time_t conversions easier. | /// variable to make struct tm -> time_t conversions easier. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010-2011, Chris Frey <cdfrey@foursquare.net>, To God be the glory | Copyright (C) 2010-2012, Chris Frey <cdfrey@foursquare.net>, To God be the glory | |||
Released to the public domain. | Released to the public domain. | |||
Included in Barry and Barrified the namespace July 2010 | Included in Barry and Barrified the namespace July 2010 | |||
*/ | */ | |||
#ifndef __TZWRAPPER_H__ | #ifndef __TZWRAPPER_H__ | |||
#define __TZWRAPPER_H__ | #define __TZWRAPPER_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include <string> | #include <string> | |||
#include <time.h> | #include <time.h> | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
usbwrap.h | usbwrap.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file usbwrap.h | /// \file usbwrap.h | |||
/// USB API wrapper | /// USB API wrapper | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2005-2011, Chris Frey | Copyright (C) 2005-2012, Chris Frey | |||
Portions Copyright (C) 2011, RealVNC Ltd. | ||||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
See the GNU General Public License in the COPYING file at the | See the GNU General Public License in the COPYING file at the | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __SB_USBWRAP_H__ | #ifndef __SB_USBWRAP_H__ | |||
#define __SB_USBWRAP_H__ | #define __SB_USBWRAP_H__ | |||
#include "dll.h" | #include "dll.h" | |||
// On Windows systems, usb.h includes <windows.h> which defines min/max, | #include <memory> | |||
// which causes trouble for other headers | #include <tr1/memory> | |||
#include <usb.h> | ||||
#undef min | ||||
#undef max | ||||
#include <vector> | #include <vector> | |||
#include <map> | #include <map> | |||
#include "error.h" | #include "error.h" | |||
#define USBWRAP_DEFAULT_TIMEOUT 30000 | #define USBWRAP_DEFAULT_TIMEOUT 30000 | |||
// Matches any product ID when calling DeviceList::MatchDevices | ||||
#define PRODUCT_ANY 0x10000 | ||||
// Indicates an unknown product ID | ||||
#define PRODUCT_UNKNOWN 0x20000 | ||||
namespace Barry { class Data; } | namespace Barry { class Data; } | |||
/// Namespace for the libusb-related wrapper classes. This namespace | /// Namespace for the libusb-related wrapper classes. This namespace | |||
/// may change in the future. | /// may change in the future. | |||
namespace Usb { | namespace Usb { | |||
/// \addtogroup exceptions | /// \addtogroup exceptions | |||
/// @{ | /// @{ | |||
/// Thrown on low level USB errors. | /// Thrown on low level USB errors. | |||
class BXEXPORT Error : public Barry::Error | class BXEXPORT Error : public Barry::Error | |||
{ | { | |||
int m_libusb_errcode; | int m_libusb_errcode; | |||
public: | public: | |||
Error(const std::string &str); | Error(const std::string &str); | |||
Error(int libusb_errcode, const std::string &str); | Error(int libusb_errcode, const std::string &str); | |||
// can return 0 in some case, if unknown error code | // can return 0 in some case, if unknown error code | |||
int libusb_errcode() const { return m_libusb_errcode; } | int libusb_errcode() const { return m_libusb_errcode; } | |||
// returns a translated system error code when using libusb 1.0 | ||||
// returns 0 if unknown or unable to translate | ||||
int system_errcode() const; | ||||
}; | }; | |||
class BXEXPORT Timeout : public Error | class BXEXPORT Timeout : public Error | |||
{ | { | |||
public: | public: | |||
Timeout(const std::string &str) : Error(str) {} | Timeout(const std::string &str) : Error(str) {} | |||
Timeout(int libusb_errcode, const std::string &str) | Timeout(int errcode, const std::string &str) | |||
: Error(libusb_errcode, str) {} | : Error(errcode, str) {} | |||
}; | }; | |||
/// @} | /// @} | |||
/// Typedefs used by the wrapper class, in the hope to make it | // Private struct for holding library specific | |||
/// easier to switch from libusb stable to devel and back. | // a unique identifier to a connected device. | |||
typedef struct usb_device* DeviceIDType; | class DeviceIDImpl; | |||
typedef struct usb_dev_handle* DeviceHandleType; | ||||
class BXEXPORT Match | class BXEXPORT DeviceID | |||
{ | { | |||
public: | ||||
std::tr1::shared_ptr<DeviceIDImpl> m_impl; | ||||
public: | ||||
// Takes ownership of impl | ||||
DeviceID(DeviceIDImpl* impl = NULL); | ||||
~DeviceID(); | ||||
const char* GetBusName() const; | ||||
uint16_t GetNumber() const; | ||||
const char* GetFilename() const; | ||||
uint16_t GetIdProduct() const; | ||||
// Utility function: returns a string that uniquely identifies | ||||
// the bus and device, regardless of which libusb you're using | ||||
std::string GetUsbName() const; | ||||
}; | ||||
// Private struct for holding a library specific | ||||
// device handle | ||||
struct DeviceHandle; | ||||
// Static functions for setting up USB | ||||
// The interface that usbwrap.cc uses | ||||
// to interact with the USB library | ||||
class BXEXPORT LibraryInterface | ||||
{ | ||||
public: | ||||
static std::string GetLastErrorString(int libusb_errcode); | ||||
/// Returns 0 if unable to translate libusb error code. | ||||
/// Note that this function assumes you already know that libusb_err | ||||
code | ||||
/// contains an actual error code, and so returns 0 (success) | ||||
/// for an unknown error. This means that "success" means error | ||||
/// if you use this function correctly, but if you pass in a success | ||||
/// code (>= 0) it will always return 0 as well. | ||||
static int TranslateErrcode(int libusb_errcode); | ||||
/// Returns true on success... pass in a pointer to int | ||||
/// if the low level error code is important to you. | ||||
static bool Init(int *libusb_errno = 0); | ||||
static void Uninit(); | ||||
static void SetDataDump(bool data_dump_mode); | ||||
}; | ||||
// Forward declaration of descriptor types. | ||||
class BXEXPORT DeviceDescriptor; | ||||
class BXEXPORT ConfigDescriptor; | ||||
class BXEXPORT InterfaceDescriptor; | ||||
// Private struct for holding library specific | ||||
// information about endpoint descriptors | ||||
struct EndpointDescriptorImpl; | ||||
// Encapsulates an endpoint descriptor | ||||
class BXEXPORT EndpointDescriptor | ||||
{ | ||||
public: | ||||
enum EpType | ||||
{ | ||||
ControlType = 0, | ||||
IsochronousType = 1, | ||||
BulkType = 2, | ||||
InterruptType = 3, | ||||
InvalidType = 0xff | ||||
}; | ||||
private: | private: | |||
struct usb_bus *m_busses; | const std::auto_ptr<EndpointDescriptorImpl> m_impl; | |||
struct usb_device *m_dev; | bool m_read; | |||
int m_vendor, m_product; | uint8_t m_addr; | |||
int m_lasterror; | EpType m_type; | |||
const char *m_busname; | ||||
const char *m_devname; | ||||
protected: | ||||
static bool ToNum(const char *str, long &num); | ||||
static bool NameCompare(const char *n1, const char *n2); | ||||
public: | public: | |||
Match(int vendor, int product, | EndpointDescriptor(InterfaceDescriptor& dev, int endpoint); | |||
const char *busname = 0, const char *devname = 0); | ~EndpointDescriptor(); | |||
~Match(); | bool IsRead() const; | |||
uint8_t GetAddress() const; | ||||
EpType GetType() const; | ||||
}; | ||||
// searches for next match, and if found, fills devid with | // Private struct for holding library specific | |||
// something you can pass on to DeviceDiscover, etc | // information about interface descriptors | |||
// returns true if next is found, false if no more | struct InterfaceDescriptorImpl; | |||
bool next_device(Usb::DeviceIDType *devid); | ||||
// Encapsulates an interface descriptor | ||||
// | ||||
// The inherited vector methods look up endpoints | ||||
class BXEXPORT InterfaceDescriptor : public std::vector<EndpointDescriptor* | ||||
> | ||||
{ | ||||
friend class EndpointDescriptor; | ||||
public: | ||||
typedef std::vector<EndpointDescriptor*> base_type; | ||||
private: | ||||
const std::auto_ptr<InterfaceDescriptorImpl> m_impl; | ||||
public: | ||||
InterfaceDescriptor(ConfigDescriptor& cfgdesc, | ||||
int interface, int altsetting); | ||||
~InterfaceDescriptor(); | ||||
uint8_t GetClass() const; | ||||
uint8_t GetNumber() const; | ||||
uint8_t GetAltSetting() const; | ||||
}; | ||||
// Private struct for holding library specific | ||||
// information about config descriptors | ||||
struct ConfigDescriptorImpl; | ||||
// Encapsulates a configuration descriptor | ||||
// | ||||
// The inherited map methods look up interface descriptors | ||||
class BXEXPORT ConfigDescriptor : public std::map<int, InterfaceDescriptor* | ||||
> | ||||
{ | ||||
friend class InterfaceDescriptor; | ||||
public: | ||||
typedef std::map<int, InterfaceDescriptor*> base_type; | ||||
private: | ||||
const std::auto_ptr<ConfigDescriptorImpl> m_impl; | ||||
public: | ||||
ConfigDescriptor(DeviceDescriptor& dev, int cfgnumber); | ||||
~ConfigDescriptor(); | ||||
uint8_t GetNumber() const; | ||||
}; | }; | |||
// Private struct for holding library specific | ||||
// information about a device descriptor | ||||
struct DeviceDescriptorImpl; | ||||
// Encapsulates a device descriptor | ||||
// | ||||
// The inherited map methods look up config descriptors | ||||
class BXEXPORT DeviceDescriptor : public std::map<int, ConfigDescriptor*> | ||||
{ | ||||
friend class ConfigDescriptor; | ||||
public: | ||||
typedef std::map<int, ConfigDescriptor*> base_type; | ||||
private: | ||||
const std::auto_ptr<DeviceDescriptorImpl> m_impl; | ||||
public: | ||||
DeviceDescriptor(DeviceID& devid); | ||||
~DeviceDescriptor(); | ||||
}; | ||||
// Private struct for holding library specific | ||||
// information for devices. | ||||
struct DeviceListImpl; | ||||
class BXEXPORT DeviceList | ||||
{ | ||||
private: | ||||
// Private implementation structure | ||||
const std::auto_ptr<DeviceListImpl> m_impl; | ||||
public: | ||||
DeviceList(); | ||||
~DeviceList(); | ||||
std::vector<DeviceID> MatchDevices(int vendor, int product, | ||||
const char *busname, const char * | ||||
devname); | ||||
}; | ||||
struct PrivateDeviceData; | ||||
class BXEXPORT Device | class BXEXPORT Device | |||
{ | { | |||
private: | private: | |||
Usb::DeviceIDType m_id; | Usb::DeviceID m_id; | |||
Usb::DeviceHandleType m_handle; | std::auto_ptr<Usb::DeviceHandle> m_handle; | |||
int m_timeout; | int m_timeout; | |||
int m_lasterror; | int m_lasterror; | |||
public: | public: | |||
Device(Usb::DeviceIDType id, int timeout = USBWRAP_DEFAULT_TIMEOUT); | Device(const Usb::DeviceID& id, int timeout = USBWRAP_DEFAULT_TIMEOU T); | |||
~Device(); | ~Device(); | |||
///////////////////////////// | ///////////////////////////// | |||
// Data access | // Data access | |||
Usb::DeviceIDType GetID() const { return m_id; } | const Usb::DeviceID& GetID() const { return m_id; } | |||
Usb::DeviceHandleType GetHandle() const { return m_handle; } | const Usb::DeviceHandle* GetHandle() const { return &*m_handle; } | |||
int GetLastError() const { return m_lasterror; } //< not thread safe ... | int GetLastError() const { return m_lasterror; } //< not thread safe ... | |||
//< use the error code stored in the exceptions to track | //< use the error code stored in the exceptions to track | |||
//< errors in threaded usage | //< errors in threaded usage | |||
void SetLastError(int err) { m_lasterror = err; } | ||||
int GetDefaultTimeout() const { return m_timeout; } | int GetDefaultTimeout() const { return m_timeout; } | |||
///////////////////////////// | ///////////////////////////// | |||
// Device information | ||||
int GetPowerLevel(); | ||||
int FindInterface(int ifaceClass); | ||||
///////////////////////////// | ||||
// Device manipulation | // Device manipulation | |||
bool SetConfiguration(unsigned char cfg); | bool SetConfiguration(unsigned char cfg); | |||
bool ClearHalt(int ep); | bool ClearHalt(int ep); | |||
bool Reset(); | bool Reset(); | |||
bool IsAttachKernelDriver(int iface); | ||||
bool DetachKernelDriver(int iface); | ||||
///////////////////////////// | ///////////////////////////// | |||
// IO functions | // IO functions | |||
bool BulkRead(int ep, Barry::Data &data, int timeout = -1); | bool BulkRead(int ep, Barry::Data &data, int timeout = -1); | |||
bool BulkWrite(int ep, const Barry::Data &data, int timeout = -1); | bool BulkWrite(int ep, const Barry::Data &data, int timeout = -1); | |||
bool BulkWrite(int ep, const void *data, size_t size, int timeout = -1); | bool BulkWrite(int ep, const void *data, size_t size, int timeout = -1); | |||
bool InterruptRead(int ep, Barry::Data &data, int timeout = -1); | bool InterruptRead(int ep, Barry::Data &data, int timeout = -1); | |||
bool InterruptWrite(int ep, const Barry::Data &data, int timeout = - 1); | bool InterruptWrite(int ep, const Barry::Data &data, int timeout = - 1); | |||
void BulkDrain(int ep, int timeout = 100); | void BulkDrain(int ep, int timeout = 100); | |||
bool ControlMsg(int requesttype, int request, int value, | ||||
int index, char *bytes, int size, int timeout); | ||||
///////////////////////////// | ///////////////////////////// | |||
// Combo functions | // Combo functions | |||
bool GetConfiguration(unsigned char &cfg); | bool GetConfiguration(unsigned char &cfg); | |||
bool SetAltInterface(int iface); | ||||
}; | }; | |||
class BXEXPORT Interface | class BXEXPORT Interface | |||
{ | { | |||
Device &m_dev; | Device &m_dev; | |||
int m_iface; | int m_iface; | |||
public: | public: | |||
Interface(Device &dev, int iface); | Interface(Device &dev, int iface); | |||
~Interface(); | ~Interface(); | |||
bool SetAltInterface(int altSetting); | ||||
}; | }; | |||
// Map of Endpoint numbers (not indexes) to endpoint descriptors | // Map of Endpoint numbers (not indexes) to endpoint descriptors | |||
struct BXEXPORT EndpointPair | struct BXEXPORT EndpointPair | |||
{ | { | |||
unsigned char read; | unsigned char read; | |||
unsigned char write; | unsigned char write; | |||
unsigned char type; | EndpointDescriptor::EpType type; | |||
EndpointPair() : read(0), write(0), type(0xff) {} | ||||
bool IsTypeSet() const { return type != 0xff; } | ||||
bool IsComplete() const { return read && write && IsTypeSet(); } | ||||
}; | ||||
class BXEXPORT EndpointDiscovery : public std::map<unsigned char, usb_endpo | ||||
int_descriptor> | ||||
{ | ||||
friend class InterfaceDiscovery; | ||||
public: | ||||
typedef std::map<unsigned char, usb_endpoint_descriptor>base_type; | ||||
typedef std::vector<EndpointPair> endpoint_arr | ||||
ay_type; | ||||
private: | ||||
bool m_valid; | ||||
endpoint_array_type m_endpoints; | ||||
BXLOCAL bool Discover(struct usb_interface_descriptor *interface, in | ||||
t epcount); | ||||
public: | ||||
EndpointDiscovery() : m_valid(false) {} | ||||
bool IsValid() const { return m_valid; } | ||||
const endpoint_array_type & GetEndpointPairs() const { return m_endp | ||||
oints; } | ||||
}; | ||||
// Map of Interface numbers (not indexes) to interface descriptors and endp | EndpointPair(); | |||
oint map | bool IsTypeSet() const; | |||
struct BXEXPORT InterfaceDesc | bool IsComplete() const; | |||
{ | bool IsBulk() const; | |||
usb_interface_descriptor desc; | ||||
EndpointDiscovery endpoints; | ||||
}; | }; | |||
class BXEXPORT InterfaceDiscovery : public std::map<int, InterfaceDesc> | class BXEXPORT EndpointPairings : public std::vector<EndpointPair> | |||
{ | { | |||
public: | public: | |||
typedef std::map<int, InterfaceDesc> base_type; | typedef std::vector<EndpointPair> base_type; | |||
private: | private: | |||
bool m_valid; | bool m_valid; | |||
BXLOCAL bool DiscoverInterface(struct usb_interface *interface); | ||||
public: | public: | |||
InterfaceDiscovery() : m_valid(false) {} | EndpointPairings(const std::vector<EndpointDescriptor*>& eps); | |||
~EndpointPairings(); | ||||
bool Discover(Usb::DeviceIDType devid, int cfgidx, int ifcount); | bool IsValid() const; | |||
bool IsValid() const { return m_valid; } | ||||
}; | ||||
// Map of Config numbers (not indexes) to config descriptors and interface | ||||
map | ||||
struct BXEXPORT ConfigDesc | ||||
{ | ||||
usb_config_descriptor desc; | ||||
InterfaceDiscovery interfaces; | ||||
}; | }; | |||
class BXEXPORT ConfigDiscovery : public std::map<unsigned char, ConfigDesc> | class BXEXPORT Match | |||
{ | { | |||
public: | ||||
typedef std::map<unsigned char, ConfigDesc> base_type; | ||||
private: | private: | |||
bool m_valid; | std::vector<DeviceID> m_list; | |||
std::vector<DeviceID>::iterator m_iter; | ||||
public: | ||||
ConfigDiscovery() : m_valid(false) {} | ||||
bool Discover(Usb::DeviceIDType devid, int cfgcount); | ||||
bool IsValid() const { return m_valid; } | ||||
}; | ||||
// Discovers all configurations, interfaces, and endpoints for a given devi | ||||
ce | ||||
class BXEXPORT DeviceDiscovery | ||||
{ | ||||
bool m_valid; | ||||
public: | ||||
usb_device_descriptor desc; | ||||
ConfigDiscovery configs; | ||||
public: | public: | |||
DeviceDiscovery(Usb::DeviceIDType devid); | // Due to USB libraries having different ownership ideas | |||
// about device IDs, Match objects must be constructed | ||||
// with a device list. | ||||
Match(DeviceList& devices, | ||||
int vendor, int product, | ||||
const char *busname = 0, const char *devname = 0); | ||||
~Match(); | ||||
bool Discover(Usb::DeviceIDType devid); | // searches for next match, and if found, fills devid with | |||
bool IsValid() const { return m_valid; } | // something you can pass on to DeviceDiscover, etc | |||
// returns true if next is found, false if no more | ||||
bool next_device(Usb::DeviceID& devid); | ||||
}; | }; | |||
} // namespace Usb | } | |||
#endif | #endif | |||
End of changes. 33 change blocks. | ||||
119 lines changed or deleted | 221 lines changed or added | |||
vbase.h | vbase.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file vbase.h | /// \file vbase.h | |||
/// Base class for vformat support | /// Base class for vformat support | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2006-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2006-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 31 | skipping to change at line 31 | |||
#ifndef __BARRY_SYNC_VBASE_H__ | #ifndef __BARRY_SYNC_VBASE_H__ | |||
#define __BARRY_SYNC_VBASE_H__ | #define __BARRY_SYNC_VBASE_H__ | |||
#include "dll.h" | #include "dll.h" | |||
#include "vsmartptr.h" | #include "vsmartptr.h" | |||
#include "vformat.h" | #include "vformat.h" | |||
#include "error.h" | #include "error.h" | |||
#include <vector> | #include <vector> | |||
namespace Barry { | ||||
class CategoryList; | ||||
} | ||||
namespace Barry { namespace Sync { | namespace Barry { namespace Sync { | |||
// | // | |||
// vTimeZone | // vTimeConverter | |||
// | // | |||
/// A virtual base class that the plugins may override, to do | /// A virtual base class that the plugins may override, to do | |||
/// time related conversions. Default implementations for these | /// time related conversions. Default implementations for these | |||
/// functions are provided, but may be overrided depending on need. | /// functions are provided, but may be overrided depending on need. | |||
/// | /// | |||
/// We do this in a "callback" style, so that it doesn't matter what | /// We do this in a "callback" style, so that it doesn't matter what | |||
/// version of the opensync library we link against, in case the | /// version of the opensync library we link against, in case the | |||
/// user wishes to use the opensync time functions. | /// user wishes to use the opensync time functions. | |||
/// | /// | |||
class BXEXPORT vTimeConverter | class BXEXPORT vTimeConverter | |||
skipping to change at line 138 | skipping to change at line 142 | |||
void Clear(); | void Clear(); | |||
vAttrPtr NewAttr(const char *name); | vAttrPtr NewAttr(const char *name); | |||
vAttrPtr NewAttr(const char *name, const char *value); | vAttrPtr NewAttr(const char *name, const char *value); | |||
void AddAttr(vAttrPtr attr); | void AddAttr(vAttrPtr attr); | |||
void AddValue(vAttrPtr &attr, const char *value); | void AddValue(vAttrPtr &attr, const char *value); | |||
void AddEncodedValue(vAttrPtr &attr, b_VFormatEncoding encoding, con st char *value, int len); | void AddEncodedValue(vAttrPtr &attr, b_VFormatEncoding encoding, con st char *value, int len); | |||
void AddParam(vAttrPtr &attr, const char *name, const char *value); | void AddParam(vAttrPtr &attr, const char *name, const char *value); | |||
void AddCategories(const Barry::CategoryList &categories); | ||||
std::string GetAttr(const char *attrname, const char *block = 0); | std::string GetAttr(const char *attrname, const char *block = 0); | |||
std::vector<std::string> GetValueVector(const char *attrname, const char *block = 0); | std::vector<std::string> GetValueVector(const char *attrname, const char *block = 0); | |||
vAttr GetAttrObj(const char *attrname, int nth = 0, const char *bloc k = 0); | vAttr GetAttrObj(const char *attrname, int nth = 0, const char *bloc k = 0); | |||
std::vector<std::string> Tokenize(const std::string &str, const char delim = ','); | std::vector<std::string> Tokenize(const std::string &str, const char delim = ','); | |||
std::string ToStringList(const std::vector<std::string> &list, const char delim = ','); | std::string ToStringList(const std::vector<std::string> &list, const char delim = ','); | |||
}; | }; | |||
}} // namespace Barry::Sync | }} // namespace Barry::Sync | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 8 lines changed or added | |||
vcard.h | vcard.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file vcard.h | /// \file vcard.h | |||
/// Conversion routines for vcards | /// Conversion routines for vcards | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2006-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2006-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 50 | skipping to change at line 50 | |||
{ | { | |||
// data to pass to external requests | // data to pass to external requests | |||
char *m_gCardData; // dynamic memory returned by vformat()... c an | char *m_gCardData; // dynamic memory returned by vformat()... c an | |||
// be used directly by the plugin, without | // be used directly by the plugin, without | |||
// overmuch allocation and freeing (see Extr act()) | // overmuch allocation and freeing (see Extr act()) | |||
std::string m_vCardData;// copy of m_gCardData, for C++ use | std::string m_vCardData;// copy of m_gCardData, for C++ use | |||
Barry::Contact m_BarryContact; | Barry::Contact m_BarryContact; | |||
protected: | protected: | |||
void AddAddress(const char *rfc_type, const Barry::PostalAddress &ad dr); | void AddAddress(const char *rfc_type, const Barry::PostalAddress &ad dr); | |||
void AddCategories(const Barry::CategoryList &categories); | ||||
void AddPhoneCond(const std::string &phone); | void AddPhoneCond(const std::string &phone); | |||
void AddPhoneCond(const char *rfc_type, const std::string &phone); | void AddPhoneCond(const char *rfc_type, const std::string &phone); | |||
void ParseAddress(vAttr &adr, Barry::PostalAddress &address); | void ParseAddress(vAttr &adr, Barry::PostalAddress &address); | |||
void ParseCategories(vAttr &cat, Barry::CategoryList &cats); | void ParseCategories(vAttr &cat, Barry::CategoryList &cats); | |||
public: | public: | |||
vCard(); | vCard(); | |||
~vCard(); | ~vCard(); | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 1 lines changed or added | |||
version.h | version.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file version.h | /// \file version.h | |||
/// Provide access to library version information | /// Provide access to library version information | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2007-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2007-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 29 | skipping to change at line 29 | |||
root directory of this project for more details. | root directory of this project for more details. | |||
*/ | */ | |||
#ifndef __BARRY_VERSION_H__ | #ifndef __BARRY_VERSION_H__ | |||
#define __BARRY_VERSION_H__ | #define __BARRY_VERSION_H__ | |||
#include "dll.h" | #include "dll.h" | |||
namespace Barry { | namespace Barry { | |||
BXEXPORT const char* Version(int &major, int &minor); | BXEXPORT const char* Version(int &logical, int &major, int &minor); | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added | |||
vevent.h | vevent.h | |||
---|---|---|---|---|
// | /// | |||
// \file vevent.h | /// \file vevent.h | |||
// Conversion routines for vevents (VCALENDAR, etc) | /// Conversion routines for vevents (VCALENDAR, etc) | |||
// | /// | |||
/* | /* | |||
Copyright (C) 2006-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2006-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 54 | skipping to change at line 54 | |||
// data to pass to external requests | // data to pass to external requests | |||
char *m_gCalData; // dynamic memory returned by vformat()... c an | char *m_gCalData; // dynamic memory returned by vformat()... c an | |||
// be used directly by the plugin, without | // be used directly by the plugin, without | |||
// overmuch allocation and freeing (see Extr act()) | // overmuch allocation and freeing (see Extr act()) | |||
std::string m_vCalData; // copy of m_gCalData, for C++ use | std::string m_vCalData; // copy of m_gCalData, for C++ use | |||
Barry::Calendar m_BarryCal; | Barry::Calendar m_BarryCal; | |||
static const char *WeekDays[7]; | static const char *WeekDays[7]; | |||
unsigned short GetMonthWeekNumFromBYDAY(const std::string& ByDay); | uint16_t GetMonthWeekNumFromBYDAY(const std::string& ByDay); | |||
unsigned short GetWeekDayIndexFromBYDAY(const std::string& ByDay); | uint16_t GetWeekDayIndexFromBYDAY(const std::string& ByDay); | |||
protected: | protected: | |||
void RecurToVCal(); | void RecurToVCal(); | |||
void RecurToBarryCal(vAttr& rrule, time_t starttime); | void RecurToBarryCal(vAttr& rrule, time_t starttime); | |||
static unsigned short GetWeekDayIndex(const char *dayname); | static uint16_t GetWeekDayIndex(const char *dayname); | |||
bool HasMultipleVEvents() const; | bool HasMultipleVEvents() const; | |||
public: | public: | |||
explicit vCalendar(vTimeConverter &vtc); | explicit vCalendar(vTimeConverter &vtc); | |||
~vCalendar(); | ~vCalendar(); | |||
const std::string& ToVCal(const Barry::Calendar &cal); | const std::string& ToVCal(const Barry::Calendar &cal); | |||
const Barry::Calendar& ToBarry(const char *vcal, uint32_t RecordId) ; | const Barry::Calendar& ToBarry(const char *vcal, uint32_t RecordId) ; | |||
const std::string& GetVCal() const { return m_vCalData; } | const std::string& GetVCal() const { return m_vCalData; } | |||
End of changes. 4 change blocks. | ||||
8 lines changed or deleted | 8 lines changed or added | |||
vjournal.h | vjournal.h | |||
---|---|---|---|---|
// | /// | |||
// \file vjournal.h | /// \file vjournal.h | |||
// Conversion routines for vjournals (VCALENDAR, etc) | /// Conversion routines for vjournals (VCALENDAR, etc) | |||
// | /// | |||
/* | /* | |||
Copyright (C) 2008-2009, Nicolas VIVIEN | Copyright (C) 2008-2009, Nicolas VIVIEN | |||
Copyright (C) 2006-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2006-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
skipping to change at line 43 | skipping to change at line 43 | |||
namespace Barry { namespace Sync { | namespace Barry { namespace Sync { | |||
// | // | |||
// vJournal | // vJournal | |||
// | // | |||
/// Class for converting between RFC 2445 iCalendar data format, | /// Class for converting between RFC 2445 iCalendar data format, | |||
/// and the Barry::Memo class. | /// and the Barry::Memo class. | |||
/// | /// | |||
class BXEXPORT vJournal : public vBase | class BXEXPORT vJournal : public vBase | |||
{ | { | |||
// external reference | ||||
vTimeConverter &m_vtc; | ||||
// data to pass to external requests | // data to pass to external requests | |||
char *m_gJournalData; // dynamic memory returned by vformat()... c an | char *m_gJournalData; // dynamic memory returned by vformat()... c an | |||
// be used directly by the plugin, without | // be used directly by the plugin, without | |||
// overmuch allocation and freeing (see Extr act()) | // overmuch allocation and freeing (see Extr act()) | |||
std::string m_vJournalData; // copy of m_gJournalData, for C++ u se | std::string m_vJournalData; // copy of m_gJournalData, for C++ u se | |||
Barry::Memo m_BarryMemo; | Barry::Memo m_BarryMemo; | |||
protected: | protected: | |||
bool HasMultipleVJournals() const; | bool HasMultipleVJournals() const; | |||
public: | public: | |||
vJournal(); | explicit vJournal(vTimeConverter &vtc); | |||
~vJournal(); | ~vJournal(); | |||
const std::string& ToMemo(const Barry::Memo &memo); | const std::string& ToMemo(const Barry::Memo &memo); | |||
const Barry::Memo& ToBarry(const char *vjournal, uint32_t Recor dId); | const Barry::Memo& ToBarry(const char *vjournal, uint32_t Recor dId); | |||
char* ExtractVJournal(); | char* ExtractVJournal(); | |||
void Clear(); | void Clear(); | |||
// This is the v-name of the innermost BEGIN/END block | // This is the v-name of the innermost BEGIN/END block | |||
End of changes. 4 change blocks. | ||||
6 lines changed or deleted | 9 lines changed or added | |||
vsmartptr.h | vsmartptr.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file vsmartptr | /// \file vsmartptr.h | |||
/// Variable 'free' smart pointer | /// Smart pointer that accepts custom 'free' functions. | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2006-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2006-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 2 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added | |||
vtodo.h | vtodo.h | |||
---|---|---|---|---|
// | /// | |||
// \file vtodo.h | /// \file vtodo.h | |||
// Conversion routines for vtodos (VCALENDAR, etc) | /// Conversion routines for vtodos (VCALENDAR, etc) | |||
// | /// | |||
/* | /* | |||
Copyright (C) 2008-2009, Nicolas VIVIEN | Copyright (C) 2008-2009, Nicolas VIVIEN | |||
Copyright (C) 2006-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2006-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 2 change blocks. | ||||
5 lines changed or deleted | 5 lines changed or added | |||
xmlparser.h | xmlparser.h | |||
---|---|---|---|---|
/// | /// | |||
/// \file xmlparser.h | /// \file xmlparser.h | |||
/// A simple XML parser (use callback on start, end and data blo ck | /// A simple XML parser (use callback on start, end and data blo ck | |||
/// | /// | |||
/* | /* | |||
Copyright (C) 2010, Nicolas VIVIEN | Copyright (C) 2010, Nicolas VIVIEN | |||
Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/) | Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/) | |||
This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||