barry.h   barry.h 
/// ///
/// \file barry.h /// \file barry.h
/// Main header file for applications /// Main header file for applications
/// ///
/* /*
Copyright (C) 2005-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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
*/ */
// This lists all the headers that the application needs. // This lists all the headers that the application needs.
// Only these headers get installed. // Only these headers get installed.
#include "data.h" #include "data.h"
#include "usbwrap.h" // to be moved to libusb someday #include "usbwrap.h" // to be moved to libusb someday
#include "common.h" // Init() #include "common.h" // Init()
#include "error.h" // exceptions #include "error.h" // exceptions
#include "configfile.h"
#include "probe.h" // device prober class #include "probe.h" // device prober class
#include "dataqueue.h" #include "dataqueue.h"
#include "socket.h" #include "socket.h"
#include "router.h" #include "router.h"
#include "protocol.h" // application-safe header #include "protocol.h" // application-safe header
#include "parser.h" #include "parser.h"
#include "builder.h" #include "builder.h"
#include "ldif.h" #include "ldif.h"
#include "ldifio.h"
#include "controller.h" #include "controller.h"
#include "m_desktop.h" #include "m_desktop.h"
#include "m_ipmodem.h" #include "m_ipmodem.h"
#include "m_serial.h" #include "m_serial.h"
#include "m_javaloader.h" #include "m_javaloader.h"
#include "m_raw_channel.h"
#include "m_jvmdebug.h" #include "m_jvmdebug.h"
#include "version.h" #include "version.h"
#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 "connector.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"
 End of changes. 5 change blocks. 
1 lines changed or deleted 6 lines changed or added


 bmp.h   bmp.h 
/// ///
/// \file bmp.h /// \file bmp.h
/// BMP conversion routines /// BMP conversion routines
/// ///
/* /*
Copyright (C) 2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2009-2011, 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


 builder.h   builder.h 
/// ///
/// \file builder.h /// \file builder.h
/// Virtual protocol packet builder wrapper /// Virtual protocol packet builder wrapper
/// ///
/* /*
Copyright (C) 2005-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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_BUILDER_H__ #ifndef __BARRY_BUILDER_H__
#define __BARRY_BUILDER_H__ #define __BARRY_BUILDER_H__
#include "dll.h" #include "dll.h"
#include "data.h"
#include <stdint.h>
#include <string>
//
// This macro can be used to automatically generate code for all known
// record types. Just #undef HANDLE_BUILDER, then #define it to whatever
// you need, then use ALL_KNOWN_BUILDER_TYPES. See parser.cc for
// various examples.
//
// These are sorted so their GetDBName()'s will display in alphabetical ord
er.
//
#define ALL_KNOWN_BUILDER_TYPES \
HANDLE_BUILDER(Contact) \
HANDLE_BUILDER(Calendar) \
HANDLE_BUILDER(CalendarAll) \
HANDLE_BUILDER(ContentStore) \
HANDLE_BUILDER(Memo) \
HANDLE_BUILDER(Task) \
namespace Barry { namespace Barry {
// forward declarations // forward declarations
class IConverter; class IConverter;
// //
// Builder class // Builder class
// //
/// Base class for the builder functor hierarchy. /// Base class for the builder functor hierarchy.
/// ///
/// This defines the API used by the Controller and Packet classes /// This defines the API used by the Controller and Packet classes
/// for building a raw device record to write to the device. /// for building a raw device record to write to the device.
/// ///
class BXEXPORT Builder class BXEXPORT Builder
{ {
public: public:
Builder() {} Builder() {}
virtual ~Builder() {} virtual ~Builder() {}
/// Called first in the sequence, to allow the application to
/// load the needed data from memory, disk, etc. If successful,
/// return true. If at the end of the series, return false.
virtual bool Retrieve(unsigned int databaseId) = 0;
/// Called to retrive the unique ID for this record.
virtual uint8_t GetRecType() const = 0;
virtual uint32_t GetUniqueId() const = 0;
/// Called before BuildFields() in order to build the header
/// for this record. Store the raw data in data, at the
/// offset given in offset. When finished, update offset to
/// point to the next spot to put new data.
virtual void BuildHeader(Data &data, size_t &offset) = 0;
/// Called to build the record field data. Store the raw data /// Called to build the record field data. Store the raw data
/// in data, using offset to know where to write. Be sure to /// in data, using offset to know where to write. Be sure to
/// update offset, and be sure to adjust the size of the data /// update offset, and be sure to adjust the size of the data
/// packet (possibly with Data::ReleaseBuffer()). /// packet (possibly with Data::ReleaseBuffer()).
virtual void BuildFields(Data &data, size_t &offset, ///
/// Returns true if successful, and false if at the end of
/// the series. Note that if EndOfFile() is false after
/// this function returns false, then there may be another
/// series available, which the next call to BuildRecord()
/// will determine.
///
virtual bool BuildRecord(DBData &data, size_t &offset,
const IConverter *ic) = 0; const IConverter *ic) = 0;
/// Same as BuildRecord, but does not care about any offsets.
/// The caller should call DBData::GetOffset() afterward
/// to discover if there is an offset to the result.
///
/// This is usually the fastest of the two functions, since
/// extra copying may be required if a specific offset is
/// given. When building records from Record classes, both
/// functions are the same speed. But when building records
/// from the device, the device decides the offset, so FetchRecord()
/// is faster, since BuildRecord requires a copy to adjust
/// to the right offset.
///
/// The caller should use the function that results in the least
/// amount of copying for the caller. If the caller doesn't
/// care about where the resulting record is in data, use
/// FetchRecord().
///
virtual bool FetchRecord(DBData &data, const IConverter *ic) = 0;
/// Sometimes a builder can have multiple databases stored
/// in it, so when Build/Fetch returns false, check if there
/// is more data with this function. This function is
/// not used by database-oriented functions, but by pipe-
/// oriented functions.
virtual bool EndOfFile() const = 0;
}; };
// //
// DBDataBuilder
//
/// Wrapper class around a DBData object, to make it easy to pass a DBData
/// object into a function or API that requires a builder. The main
/// advantage to this is that the Builder API allows for movement of
/// data, depending on the required offsets.
///
class BXEXPORT DBDataBuilder : public Builder
{
const DBData &m_orig;
public:
explicit DBDataBuilder(const DBData &orig);
virtual ~DBDataBuilder();
virtual bool BuildRecord(DBData &data, size_t &offset,
const IConverter *ic);
virtual bool FetchRecord(DBData &data, const IConverter *ic);
virtual bool EndOfFile() const;
};
//
// SetDBData
//
/// Contains the proper way to convert a record object into a DBData object
.
///
template <class RecordT>
void SetDBData(const RecordT &rec, DBData &data, size_t &offset,
const IConverter *ic)
{
data.SetVersion(DBData::REC_VERSION_1);
data.SetOffset(offset);
data.SetDBName(RecordT::GetDBName());
data.SetIds(rec.GetRecType(), rec.GetUniqueId());
rec.BuildHeader(data.UseData(), offset);
rec.BuildFields(data.UseData(), offset, ic);
}
//
// RecordBuilder template class // RecordBuilder template class
// //
/// Template class for easy creation of specific protocol packet builder /// Template class for easy creation of specific protocol packet builder
/// objects. This template takes the following template arguments: /// objects. This template takes the following template arguments:
/// ///
/// - RecordT: One of the record classes in record.h /// - RecordT: One of the record classes in record.h
/// - StorageT: A custom storage functor class. An object of this type /// - StorageT: A custom storage functor class. An object of this type
/// will be called as a function with empty Record as an /// will be called as a function with empty Record as an
/// argument. The storage class is expected to fill the /// argument. The storage class is expected to fill the
/// record object in preparation for building the packet /// record object in preparation for building the packet
skipping to change at line 94 skipping to change at line 170
/// ///
/// <pre> /// <pre>
/// FIXME /// FIXME
/// </pre> /// </pre>
/// ///
template <class RecordT, class StorageT> template <class RecordT, class StorageT>
class RecordBuilder : public Builder class RecordBuilder : public Builder
{ {
StorageT *m_storage; StorageT *m_storage;
bool m_owned; bool m_owned;
bool m_record_loaded;
bool m_end_of_file;
RecordT m_rec; RecordT m_rec;
public: public:
/// Constructor that references an externally managed storage object . /// Constructor that references an externally managed storage object .
RecordBuilder(StorageT &storage) RecordBuilder(StorageT &storage)
: m_storage(&storage), m_owned(false) {} : m_storage(&storage)
, m_owned(false)
, m_record_loaded(false)
, m_end_of_file(false)
{
}
/// Constructor that references a locally managed storage object. /// Constructor that references a locally managed storage object.
/// The pointer passed in will be stored, and freed when this class /// The pointer passed in will be stored, and freed when this class
/// is destroyed. It is safe to call this constructor with /// is destroyed. It is safe to call this constructor with
/// a 'new'ly created storage object. /// a 'new'ly created storage object.
RecordBuilder(StorageT *storage) RecordBuilder(StorageT *storage)
: m_storage(storage), m_owned(true) {} : m_storage(storage)
, m_owned(true)
, m_record_loaded(false)
, m_end_of_file(false)
{
}
~RecordBuilder() ~RecordBuilder()
{ {
if( this->m_owned ) if( this->m_owned )
delete m_storage; delete m_storage;
} }
virtual bool Retrieve(unsigned int databaseId) virtual bool BuildRecord(DBData &data, size_t &offset,
const IConverter *ic)
{ {
return (*m_storage)(m_rec, databaseId); if( m_end_of_file )
} return false;
virtual uint8_t GetRecType() const if( !(*m_storage)(m_rec, *this) ) {
{ m_end_of_file = true;
return m_rec.GetRecType(); return false;
} }
virtual uint32_t GetUniqueId() const SetDBData(m_rec, data, offset, ic);
{ return true;
return m_rec.GetUniqueId();
} }
/// Functor member called by Controller::SaveDatabase() during virtual bool FetchRecord(DBData &data, const IConverter *ic)
/// processing.
virtual void BuildHeader(Data &data, size_t &offset)
{ {
m_rec.BuildHeader(data, offset); size_t offset = 0;
return BuildRecord(data, offset, ic);
} }
virtual void BuildFields(Data &data, size_t &offset, const IConverte r *ic) virtual bool EndOfFile() const
{ {
m_rec.BuildFields(data, offset, ic); return m_end_of_file;
} }
}; };
// //
// RecordFetch template class // RecordFetch template class
// //
/// Generic record fetch class, to help with using records without /// Generic record fetch class, to help with using records without
/// builder classes. /// builder classes.
/// ///
template <class RecordT> template <class RecordT>
class RecordFetch class RecordFetch
{ {
const RecordT &m_rec; const RecordT &m_rec;
mutable bool m_done; mutable bool m_done;
public: public:
RecordFetch(const RecordT &rec) : m_rec(rec), m_done(false) {} RecordFetch(const RecordT &rec) : m_rec(rec), m_done(false) {}
bool operator()(RecordT &rec, unsigned int dbId) const bool operator()(RecordT &rec, Builder &) const
{ {
if( m_done ) if( m_done )
return false; return false;
rec = m_rec; rec = m_rec;
m_done = true; m_done = true;
return true; return true;
} }
}; };
} // namespace Barry } // namespace Barry
 End of changes. 18 change blocks. 
36 lines changed or deleted 125 lines changed or added


 cod.h   cod.h 
/// ///
/// \file cod.h /// \file cod.h
/// COD file API /// COD file API
/// ///
/* /*
Copyright (C) 2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2009-2011, 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 55 skipping to change at line 55
// 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"
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 bool IsVerbose();
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 2 change blocks. 
1 lines changed or deleted 3 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 "usbwrap.h"
#include "socket.h" #include "socket.h"
#include "pin.h"
#include "probe.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;
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;
} }
// //
// Controller class // Controller class
// //
/// The main interface class. This class coordinates the communication to /// The main interface class. This class coordinates the communication to
/// a single handheld. This class also owns the only Usb::Device object /// a single handheld. This class also owns the only Usb::Device object
/// the handheld. All other classes reference this one for the low level /// the handheld. All other classes reference this one for the low level
/// device object. This class owns the only SocketZero object as well, /// device object. This class owns the only SocketZero object as well,
/// which is the object that any SocketRoutingQueue is plugged into /// which is the object that any SocketRoutingQueue is plugged into
skipping to change at line 76 skipping to change at line 78
/// your controller object into these mode constructors /// your controller object into these mode constructors
/// to create the mode. /// to create the mode.
/// ///
class BXEXPORT Controller class BXEXPORT Controller
{ {
friend class Barry::Mode::Mode; friend class Barry::Mode::Mode;
friend class Barry::Mode::IpModem; friend class Barry::Mode::IpModem;
friend class Barry::Mode::Serial; friend class Barry::Mode::Serial;
friend class Barry::Mode::JavaLoader; friend class Barry::Mode::JavaLoader;
friend class Barry::Mode::JVMDebug; friend class Barry::Mode::JVMDebug;
friend class Barry::Mode::RawChannel;
public: public:
/// Handheld mode type /// Handheld mode type
enum ModeType { enum ModeType {
Unspecified, //< default on start up (unused) Unspecified, //< default on start up (unused)
Bypass, //< unsupported, unknown Bypass, //< unsupported, unknown
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 UsbSerCtrl, //< internally used behind the scene
s s
RawChannel //< raw channel
}; };
private: private:
ProbeResult m_result; ProbeResult m_result;
Usb::Device m_dev; Usb::Device m_dev;
Usb::Interface *m_iface; Usb::Interface *m_iface;
uint32_t m_pin; Pin m_pin;
SocketZero m_zero; SocketZero m_zero;
SocketRoutingQueue *m_queue; //< ptr to external object; no delet e 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
public: public:
explicit Controller(const ProbeResult &device); explicit Controller(const ProbeResult &device,
Controller(const ProbeResult &device, SocketRoutingQueue &queue); int default_timeout = USBWRAP_DEFAULT_TIMEOUT);
Controller(const ProbeResult &device, SocketRoutingQueue &queue,
int default_timeout = USBWRAP_DEFAULT_TIMEOUT);
~Controller(); ~Controller();
bool HasQueue() const { return m_queue; } bool HasQueue() const { return m_queue; }
const ProbeResult& GetProbeResult() const { return m_result; } const ProbeResult& GetProbeResult() const { return m_result; }
}; };
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 8 change blocks. 
6 lines changed or deleted 13 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 __SB_DATA_H__ #ifndef __SB_DATA_H__
#define __SB_DATA_H__ #define __SB_DATA_H__
#include "dll.h" #include "dll.h"
#include <iosfwd> #include <iosfwd>
#include <vector> #include <vector>
#include <string>
#include <stdint.h>
namespace Barry { namespace Barry {
class BXEXPORT Data class BXEXPORT Data
{ {
unsigned char *m_data; unsigned char *m_data;
size_t m_bufsize; //< size of m_data buffer allocated size_t m_bufsize; //< size of m_data buffer allocated
size_t m_datasize; //< number of bytes of actual data size_t m_datasize; //< number of bytes of actual data
int m_endpoint; int m_endpoint;
skipping to change at line 87 skipping to change at line 89
// //
// 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.
// //
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);
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 119 skipping to change at line 122
void Dump(std::ostream &os) const; void Dump(std::ostream &os) const;
}; };
BXEXPORT std::ostream& operator<< (std::ostream &os, const Diff &diff); BXEXPORT std::ostream& operator<< (std::ostream &os, const Diff &diff);
// utility functions // utility functions
BXEXPORT bool LoadDataArray(const std::string &filename, std::vector<Data> &array); BXEXPORT bool LoadDataArray(const std::string &filename, std::vector<Data> &array);
BXEXPORT bool ReadDataArray(std::istream &is, std::vector<Data> &array); BXEXPORT bool ReadDataArray(std::istream &is, std::vector<Data> &array);
//
// DBData
//
/// Database record data class. The purpose of this class is to contain
/// the raw data that flows between low level activity such as device
/// read/writes, backup read/writes, and record parsing.
///
/// This class contains the low level record data block, unparsed, as well
/// as the surrounding meta data, such as the database name it belongs
/// to, the Unique ID, the Rec Type, and format version/type based on what
/// commands were used to extract the data from the device. (When using
/// newer commands, the format of the records, potentially including the
/// individual field type codes, are different.)
///
/// Possible bi-directional data flow in all of Barry:
/// Note that this class, DBData, represents the data+meta stage.
///
/// data+meta <-> device
/// data+meta <-> backup file
/// data+meta <-> record object
/// record object <-> boost serialization
/// contact record object <-> ldif
///
/// Possible uni-directional data flow in all of Barry:
///
/// record object -> text dump
///
class BXEXPORT DBData
{
public:
enum RecordFormatVersion
{
REC_VERSION_1,
REC_VERSION_2
};
private:
// record meta data
RecordFormatVersion m_version;
std::string m_dbName;
uint8_t m_recType;
uint32_t m_uniqueId;
size_t m_offset;
// the raw data block, internal
Data *m_localData;
// the data block to use... could be external or internal,
// and does not change for the life of the object
Data &m_data;
public:
/// Default constructor, constructs an empty local Data object
DBData();
/// Constructs a local Data object that points to external memory
DBData(const void *ValidData, size_t size);
DBData(RecordFormatVersion ver, const std::string &dbName,
uint8_t recType, uint32_t uniqueId, size_t offset,
const void *ValidData, size_t size);
/// If copy == false, constructs an external Data object, no local.
/// If copy == true, constructs an internal Data object copy
/// For speed, set copy to false.
/// If you want Copy On Write behaviour, similar to Data(buf,size),
/// then use the above (buf, size) constructor, not this one,
/// since this constructor uses Data's copy constructor.
DBData(Data &externalData, bool copy);
DBData(RecordFormatVersion ver, const std::string &dbName,
uint8_t recType, uint32_t uniqueId, size_t offset,
Data &externalData, bool copy);
~DBData();
// access meta data
RecordFormatVersion GetVersion() const { return m_version; }
const std::string& GetDBName() const { return m_dbName; }
uint8_t GetRecType() const { return m_recType; }
uint32_t GetUniqueId() const { return m_uniqueId; }
size_t GetOffset() const { return m_offset; }
const Data& GetData() const { return m_data; }
Data& UseData();
// operations
void SetVersion(RecordFormatVersion ver)
{
m_version = ver;
}
void SetDBName(const std::string &dbName)
{
m_dbName = dbName;
}
void SetIds(uint8_t recType, uint32_t uniqueId)
{
m_recType = recType;
m_uniqueId = uniqueId;
}
void SetOffset(size_t offset)
{
m_offset = offset;
}
void CopyMeta(const DBData &src)
{
m_version = src.m_version;
m_dbName = src.m_dbName;
m_recType = src.m_recType;
m_uniqueId = src.m_uniqueId;
m_offset = src.m_offset;
}
DBData& operator=(const DBData &other);
};
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 4 change blocks. 
1 lines changed or deleted 122 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2007-2011, 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


 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 63 skipping to change at line 63
#define BXEXPORT __attribute__ ((visibility("default"))) #define BXEXPORT __attribute__ ((visibility("default")))
#define BXLOCAL __attribute__ ((visibility("hidden"))) #define BXLOCAL __attribute__ ((visibility("hidden")))
#else #else
#define BXEXPORT #define BXEXPORT
#define BXLOCAL #define BXLOCAL
#endif #endif
//
// Add this to the end of variable argument function declarations.
// For example:
//
// void log(const char *msg, ...) BARRY_GCC_FORMAT_CHECK(1, 2);
//
// This tells GCC that the first argument is the format string, and
// the second is the first variable argument to check.
//
// If you use this inside a class, you need to allow for the invisible
// 'this' pointer:
//
// class Trace {
// public:
// void logf(const char *msg, ...) BARRY_GCC_FORMAT_CHECK(2, 3);
// };
//
#if __GNUC__
#define BARRY_GCC_FORMAT_CHECK(a,b) __attribute__ ((format(printf, a, b)))
#else
#define BARRY_GCC_FORMAT_CHECK(a,b)
#endif
#endif #endif
 End of changes. 2 change blocks. 
1 lines changed or deleted 24 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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_ERROR_H__ #ifndef __BARRY_ERROR_H__
#define __BARRY_ERROR_H__ #define __BARRY_ERROR_H__
#include "dll.h" #include "dll.h"
#include "pin.h"
#include <stdexcept> #include <stdexcept>
#include <stdint.h> #include <stdint.h>
namespace Barry { namespace Barry {
/// \addtogroup exceptions /// \addtogroup exceptions
/// @{ /// @{
// //
// Error class // Error class
skipping to change at line 77 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; }
}; };
// //
// PinNotFound
//
/// 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 pin is Valid(), then the specified pin number was not available.
/// probe_count is the number of devices found during the probe.
///
class BXEXPORT PinNotFound : public Barry::Error
{
Barry::Pin m_pin;
int m_probe_count;
public:
PinNotFound(Barry::Pin pin, int probe_count)
: Barry::Error("PIN not found: " + pin.Str())
, m_pin(pin)
, m_probe_count(probe_count)
{}
const Barry::Pin& pin() const { return m_pin; }
int probe_count() const { return m_probe_count; }
};
//
// BadData // BadData
// //
/// Thrown by record classes if their data is invalid and cannot be /// Thrown by record classes if their data is invalid and cannot be
/// uploaded to the Blackberry. /// uploaded to the Blackberry.
/// ///
class BXEXPORT BadData : public Barry::Error class BXEXPORT BadData : public Barry::Error
{ {
public: public:
BadData(const std::string &str) BadData(const std::string &str)
: Barry::Error(str) : Barry::Error(str)
skipping to change at line 105 skipping to change at line 130
class BXEXPORT BadSize : public Barry::Error class BXEXPORT BadSize : public Barry::Error
{ {
unsigned int m_packet_size, unsigned int m_packet_size,
m_data_buf_size, m_data_buf_size,
m_required_size; m_required_size;
BXLOCAL static std::string GetMsg(const char *msg, unsigned int d, u nsigned int r); BXLOCAL static std::string GetMsg(const char *msg, unsigned int d, u nsigned int r);
BXLOCAL static std::string GetMsg(unsigned int p, unsigned int d, un signed int r); BXLOCAL static std::string GetMsg(unsigned int p, unsigned int d, un signed int r);
public: public:
BadSize(const char *msg, unsigned int data_size, unsigned int requir BadSize(const char *msg, unsigned int data_size, unsigned int requir
ed_size) ed_size);
: Barry::Error(GetMsg(msg, data_size, required_size))
, m_packet_size(0)
, m_data_buf_size(data_size)
, m_required_size(required_size)
{}
BadSize(unsigned int packet_size, BadSize(unsigned int packet_size,
unsigned int data_buf_size, unsigned int data_buf_size,
unsigned int required_size) unsigned int required_size);
: Barry::Error(GetMsg(packet_size, data_buf_size, required_s
ize))
, m_packet_size(packet_size)
, m_data_buf_size(data_buf_size)
, m_required_size(required_size)
{}
unsigned int packet_size() const { return m_packet_size; } unsigned int packet_size() const { return m_packet_size; }
unsigned int data_buf_size() const { return m_data_buf_size; } unsigned int data_buf_size() const { return m_data_buf_size; }
unsigned int required_size() const { return m_required_size; } unsigned int required_size() const { return m_required_size; }
}; };
// //
// ErrnoError // ErrnoError
// //
/// System error that provides an errno error code. /// System error that provides an errno error code.
/// ///
class BXEXPORT ErrnoError : public Barry::Error class BXEXPORT ErrnoError : public Barry::Error
{ {
int m_errno; int m_errno;
static std::string GetMsg(const std::string &msg, int err); BXLOCAL static std::string GetMsg(const std::string &msg, int err);
protected:
ErrnoError(const std::string &msg); // for derived classes
public: public:
ErrnoError(const std::string &msg, int err) ErrnoError(const std::string &msg, int err);
: Barry::Error(GetMsg(msg, err))
, m_errno(err)
{}
int error_code() const { return m_errno; } int error_code() const { return m_errno; }
}; };
// //
// ConfigFileError
//
/// Thrown by the ConfigFile class when encountering a serious system
/// error while loading the global config file for a given PIN.
///
class BXEXPORT ConfigFileError : public Barry::ErrnoError
{
public:
ConfigFileError(const char *msg) : Barry::ErrnoError(msg) {}
ConfigFileError(const char *msg, int err)
: Barry::ErrnoError(msg, err)
{}
};
//
// BadPackedFormat // BadPackedFormat
// //
/// Thrown by record classes that don't recognize a given packed format cod e. /// Thrown by record classes that don't recognize a given packed format cod e.
/// This exception is mostly handled internally, but is published here /// This exception is mostly handled internally, but is published here
/// just in case it escapes. /// just in case it escapes.
/// ///
class BXEXPORT BadPackedFormat : public Barry::Error class BXEXPORT BadPackedFormat : public Barry::Error
{ {
uint8_t m_format; uint8_t m_format;
skipping to change at line 184 skipping to change at line 214
public: public:
BadPacket(uint8_t response, const std::string &msg) BadPacket(uint8_t response, const std::string &msg)
: Barry::Error(msg) : Barry::Error(msg)
, m_response(response) , m_response(response)
{} {}
uint8_t response() const { return m_response; } uint8_t response() const { return m_response; }
}; };
//
// ConvertError
//
/// Thrown by the vformat related barrysync library classes.
///
class BXEXPORT ConvertError : public Barry::Error
{
public:
ConvertError(const std::string &msg) : Barry::Error(msg) {}
};
//
// BackupError
//
/// Thrown by the Backup parser class when there is a problem with the
/// low level file operation.
///
class BXEXPORT BackupError : public Barry::Error
{
public:
BackupError(const std::string &str) : Error(str) {}
};
//
// RestoreError
//
/// Thrown by the Restore builder class when there is a problem with the
/// low level file operation.
///
class BXEXPORT RestoreError : public Barry::Error
{
public:
RestoreError(const std::string &str) : Error(str) {}
};
/// @} /// @}
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 9 change blocks. 
20 lines changed or deleted 84 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2008-2011, 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


 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 178 skipping to change at line 178
virtual std::string WorkAddress1(const Barry::Contact &con) const; virtual std::string WorkAddress1(const Barry::Contact &con) const;
virtual std::string WorkAddress2(const Barry::Contact &con) const; virtual std::string WorkAddress2(const Barry::Contact &con) const;
virtual std::string WorkAddress3(const Barry::Contact &con) const; virtual std::string WorkAddress3(const Barry::Contact &con) const;
virtual std::string WorkCity(const Barry::Contact &con) const; virtual std::string WorkCity(const Barry::Contact &con) const;
virtual std::string WorkProvince(const Barry::Contact &con) const; virtual std::string WorkProvince(const Barry::Contact &con) const;
virtual std::string WorkPostalCode(const Barry::Contact &con) const; virtual std::string WorkPostalCode(const Barry::Contact &con) const;
virtual std::string WorkCountry(const Barry::Contact &con) const; virtual std::string WorkCountry(const Barry::Contact &con) const;
virtual std::string JobTitle(const Barry::Contact &con) const; virtual std::string JobTitle(const Barry::Contact &con) const;
virtual std::string PublicKey(const Barry::Contact &con) const; virtual std::string PublicKey(const Barry::Contact &con) const;
virtual std::string Notes(const Barry::Contact &con) const; virtual std::string Notes(const Barry::Contact &con) const;
virtual std::string Image(const Barry::Contact &con) const;
// calculated values... // calculated values...
virtual std::string WorkPostalAddress(const Barry::Contact &con) con st; virtual std::string WorkPostalAddress(const Barry::Contact &con) con st;
virtual std::string HomePostalAddress(const Barry::Contact &con) con st; virtual std::string HomePostalAddress(const Barry::Contact &con) con st;
virtual std::string FullName(const Barry::Contact &con) const; virtual std::string FullName(const Barry::Contact &con) const;
virtual std::string FQDN(const Barry::Contact &con) const; virtual std::string FQDN(const Barry::Contact &con) const;
// //
// Array modifier functions for above Access functions // Array modifier functions for above Access functions
// //
skipping to change at line 217 skipping to change at line 218
virtual void SetWorkAddress1(Barry::Contact &con, const std::string &val) const; virtual void SetWorkAddress1(Barry::Contact &con, const std::string &val) const;
virtual void SetWorkAddress2(Barry::Contact &con, const std::string &val) const; virtual void SetWorkAddress2(Barry::Contact &con, const std::string &val) const;
virtual void SetWorkAddress3(Barry::Contact &con, const std::string &val) const; virtual void SetWorkAddress3(Barry::Contact &con, const std::string &val) const;
virtual void SetWorkCity(Barry::Contact &con, const std::string &val ) const; virtual void SetWorkCity(Barry::Contact &con, const std::string &val ) const;
virtual void SetWorkProvince(Barry::Contact &con, const std::string &val) const; virtual void SetWorkProvince(Barry::Contact &con, const std::string &val) const;
virtual void SetWorkPostalCode(Barry::Contact &con, const std::strin g &val) const; virtual void SetWorkPostalCode(Barry::Contact &con, const std::strin g &val) const;
virtual void SetWorkCountry(Barry::Contact &con, const std::string & val) const; virtual void SetWorkCountry(Barry::Contact &con, const std::string & val) const;
virtual void SetJobTitle(Barry::Contact &con, const std::string &val ) const; virtual void SetJobTitle(Barry::Contact &con, const std::string &val ) const;
virtual void SetPublicKey(Barry::Contact &con, const std::string &va l) const; virtual void SetPublicKey(Barry::Contact &con, const std::string &va l) const;
virtual void SetNotes(Barry::Contact &con, const std::string &val) c onst; virtual void SetNotes(Barry::Contact &con, const std::string &val) c onst;
virtual void SetImage(Barry::Contact &con, const std::string &val) c onst;
virtual void SetWorkPostalAddress(Barry::Contact &con, const std::st ring &val) const; virtual void SetWorkPostalAddress(Barry::Contact &con, const std::st ring &val) const;
virtual void SetHomePostalAddress(Barry::Contact &con, const std::st ring &val) const; virtual void SetHomePostalAddress(Barry::Contact &con, const std::st ring &val) const;
virtual void SetFullName(Barry::Contact &con, const std::string &val ) const; virtual void SetFullName(Barry::Contact &con, const std::string &val ) const;
virtual void SetFQDN(Barry::Contact &con, const std::string &val) co nst; virtual void SetFQDN(Barry::Contact &con, const std::string &val) co nst;
// //
// Name heuristics // Name heuristics
// //
virtual void ClearHeuristics(); virtual void ClearHeuristics();
 End of changes. 3 change blocks. 
1 lines changed or deleted 3 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2008-2011, 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
public: public:
LogLock(); LogLock();
~LogLock(); ~LogLock();
}; };
BXEXPORT bool LogVerbose(); BXEXPORT bool LogVerbose();
BXEXPORT std::ostream* GetLogStream(); BXEXPORT std::ostream* GetLogStream();
} // namespace Barry } // namespace Barry
#define barrylog(x) { Barry::LogLock lock; (*Barry::GetLogStream()) << x << std::endl; } #define barrylog(x) { ::Barry::LogLock lock; (*::Barry::GetLogStream()) << x << std::endl; }
// controlled by command line -v switch // controlled by command line -v switch
#define barryverbose(x) if(Barry::LogVerbose()) { Barry::LogLock loc k; (*Barry::GetLogStream()) << x << std::endl; } #define barryverbose(x) if(::Barry::LogVerbose()) { ::Barry::LogLock lock; (*::Barry::GetLogStream()) << x << std::endl; }
#endif // __BARRY_LOG_H__ #endif // __BARRY_LOG_H__
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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_M_DESKTOP_H__ #ifndef __BARRY_M_DESKTOP_H__
#define __BARRY_M_DESKTOP_H__ #define __BARRY_M_DESKTOP_H__
#include "dll.h" #include "dll.h"
#include "m_mode_base.h" #include "m_mode_base.h"
#include "data.h"
#include "socket.h" #include "socket.h"
#include "record.h" #include "record.h"
#include "parser.h"
#include "builder.h"
namespace Barry { namespace Barry {
// forward declarations // forward declarations
class Parser; class Parser;
class Builder;
class IConverter; class IConverter;
namespace Mode { namespace Mode {
class DBLoader;
// //
// Desktop class // Desktop class
// //
/// The main interface class to the device databases. /// The main interface class to the device databases.
/// ///
/// To use this class, use the following steps: /// To use this class, use the following steps:
/// ///
/// - Create a Controller object (see Controller class for more details) /// - Create a Controller object (see Controller class for more details)
/// - Create this Mode::Desktop object, passing in the Controller /// - Create this Mode::Desktop object, passing in the Controller
/// object during construction /// object during construction
/// - Call Open() to open database socket and finish constructing. /// - Call Open() to open database socket and finish constructing.
/// - Call GetDBDB() to get the device's database database /// - Call GetDBDB() to get the device's database database
/// - Call GetDBID() to get a database ID by name /// - Call GetDBID() to get a database ID by name
/// - Call LoadDatabase() to retrieve and store a database /// - Call LoadDatabase() to retrieve and store a database
/// ///
class BXEXPORT Desktop : public Mode class BXEXPORT Desktop : public Mode
{ {
friend class DBLoader;
public: public:
enum CommandType { Unknown, DatabaseAccess }; enum CommandType { Unknown, DatabaseAccess };
private: private:
// packet data
Data m_command, m_response;
CommandTable m_commandTable; CommandTable m_commandTable;
DatabaseDatabase m_dbdb; DatabaseDatabase m_dbdb;
// external objects (optional, can be null) // external objects (optional, can be null)
const IConverter *m_ic; const IConverter *m_ic;
protected: protected:
void LoadCommandTable(); void LoadCommandTable();
void LoadDBDB(); void LoadDBDB();
skipping to change at line 119 skipping to change at line 128
template <class RecordT, class StorageT> void LoadDatabaseByType(Sto rageT &store); template <class RecordT, class StorageT> void LoadDatabaseByType(Sto rageT &store);
template <class RecordT, class StorageT> void SaveDatabaseByType(Sto rageT &store); template <class RecordT, class StorageT> void SaveDatabaseByType(Sto rageT &store);
template <class StorageT> void LoadDatabaseByName(const std::string &name, StorageT &store); template <class StorageT> void LoadDatabaseByName(const std::string &name, StorageT &store);
template <class StorageT> void SaveDatabaseByName(const std::string &name, StorageT &store); template <class StorageT> void SaveDatabaseByName(const std::string &name, StorageT &store);
template <class RecordT> void AddRecordByType(uint32_t recordId, con st RecordT &rec); template <class RecordT> void AddRecordByType(uint32_t recordId, con st RecordT &rec);
}; };
}} // namespace Barry::Mode // used to hold internal-only state
struct DBLoaderData;
//
// DBLoader
//
/// Database Loader operation class. Encapsulates the load / save
/// logic of Desktop::LoadDatabase() and someday Desktop::SaveDatabase()
/// in such a way that the loading of individual records is
/// controllable by the user, instead of using the parser callback mechanis
m.
///
/// This class can be reused to load / save multiple databases, but
/// do not call Desktop members while a load operation is in progress.
///
class BXEXPORT DBLoader
{
Desktop &m_desktop;
Data m_send;
bool m_loading;
std::string m_dbName;
DBLoaderData *m_loader;
public:
explicit DBLoader(Desktop &desktop);
~DBLoader();
/// Do not call Desktop members if this is true.
bool IsBusy() const { return m_loading; }
// caller-controllable load/save operations... if
// these functions return true, then new data has
// just been loaded into the data object passed to
// the constructor
//
// Both of these functions use a DBData object in order
// to pass buffers from application code all the way down
// to the socket level, to avoid copies wherever possible.
bool StartDBLoad(unsigned int dbId, DBData &data);
bool GetNextRecord(DBData &data);
};
} // namespace Barry::Mode
//
// DeviceBuilder
//
/// Takes a list of database dbId's and behaves like a Builder,
/// trying to avoid copies where possible on the device loading end.
///
class BXEXPORT DeviceBuilder : public Builder
{
typedef unsigned int dbid_type;
struct DBLabel
{
dbid_type id;
std::string name;
DBLabel(dbid_type id, const std::string &name)
: id(id)
, name(name)
{
}
};
typedef std::vector<DBLabel> list_type;
// list of databases to fetch during build
list_type m_dbIds;
list_type::iterator m_current;
bool m_started;
Mode::Desktop &m_desktop;
// loader object to use optimized batch loading while
// giving per-record control
Mode::DBLoader m_loader;
public:
explicit DeviceBuilder(Mode::Desktop &desktop);
// searches the dbdb from the desktop to find the dbId,
// returns false if not found, and adds it to the list of
// databases to retrieve if found
bool Add(const std::string &dbname);
// adds all databases found in the given dbdb
void Add(const Barry::DatabaseDatabase &dbdb);
/// sets the internal iterator to the start of the list
/// in order to perform a fresh run
void Restart() { m_current = m_dbIds.begin(); m_started = false; }
//
// Builder overrides
//
// has both BuildRecord() and Retrieve() functionality,
// and uses data all the way down to the socket level copy
virtual bool BuildRecord(DBData &data, size_t &offset,
const IConverter *ic);
virtual bool FetchRecord(DBData &data, const IConverter *ic);
virtual bool EndOfFile() const;
};
//
// DeviceParser
//
/// A parser class that "parses" raw data into a device. Basically this
/// is a pipe-oriented way to call SaveDatabase().
///
/// Note that this is a multi-record parser. For each incoming DBData
/// that has a new DBName, a new save will be started. There is no
/// way to filter out records, except via the callback, so the easiest
/// way to filter out records by database name is on the Builder side.
///
class BXEXPORT DeviceParser : public Barry::Parser
{
public:
enum WriteMode {
/// Similar to SaveDatabase(). Erases all records from
/// the existing database and then uploads all new records.
ERASE_ALL_WRITE_ALL,
/// Adds any new records, and for records with Unique IDs
/// that already exist, overwrite them.
INDIVIDUAL_OVERWRITE,
/// Adds any new records, but if a record exists with the
/// current Unique ID, skip that record and don't write it
/// to the device.
ADD_BUT_NO_OVERWRITE,
/// Adds all incoming records as brand new records, generati
ng
/// a new Unique ID for each one, and leaving any existing
/// records intact.
ADD_WITH_NEW_ID,
/// Calls the virtual function DecideWrite(...) for each
/// record, passing in the data. DecideWrite() returns one
/// of these WriteMode values.
DECIDE_BY_CALLBACK,
/// Primarily used by DecideWrite(), and causes the current
/// record to not be written.
DROP_RECORD
};
private:
Mode::Desktop &m_desktop;
WriteMode m_mode;
std::string m_current_db;
unsigned int m_current_dbid;
RecordStateTable m_rstate;
protected:
void StartDB(const DBData &data, const IConverter *ic);
void WriteNext(const DBData &data, const IConverter *ic);
public:
DeviceParser(Mode::Desktop &desktop, WriteMode mode);
virtual ~DeviceParser();
/// Callback... you must derive and override this if you use
/// the DECIDE_BY_CALLBACK mode.
/// May be called multiple times per record.
virtual WriteMode DecideWrite(const DBData &record) const
{
return DROP_RECORD;
}
/// Parser overrides
virtual void ParseRecord(const DBData &data, const IConverter *ic);
};
} // namespace Barry
#endif #endif
 End of changes. 8 change blocks. 
3 lines changed or deleted 190 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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
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() ) if( name == Contact::GetDBName() )
LoadDatabaseByType<Contact>(store); LoadDatabaseByType<Contact>(store);
else if( name == Message::GetDBName() ) else if( name == Message::GetDBName() )
LoadDatabaseByType<Message>(store); LoadDatabaseByType<Message>(store);
else if( name == Calendar::GetDBName() ) else if( name == Calendar::GetDBName() )
LoadDatabaseByType<Calendar>(store); LoadDatabaseByType<Calendar>(store);
else if( name == CalendarAll::GetDBName() )
LoadDatabaseByType<CalendarAll>(store);
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() ) if( name == Contact::GetDBName() )
SaveDatabaseByType<Contact>(store); SaveDatabaseByType<Contact>(store);
else if( name == Message::GetDBName() ) else if( name == Message::GetDBName() )
SaveDatabaseByType<Message>(store); SaveDatabaseByType<Message>(store);
else if( name == Calendar::GetDBName() ) else if( name == Calendar::GetDBName() )
SaveDatabaseByType<Calendar>(store); SaveDatabaseByType<Calendar>(store);
else if( name == CalendarAll::GetDBName() )
SaveDatabaseByType<CalendarAll>(store);
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. 
1 lines changed or deleted 5 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2008-2011, 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 33 skipping to change at line 33
*/ */
#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 "socket.h"
#include "record.h" #include "record.h"
#include "data.h" #include "data.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;
class JLDirectoryEntry; class JLDirectoryEntry;
skipping to change at line 126 skipping to change at line 127
}; };
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const JLEventlog &log) { BXEXPORT inline std::ostream& operator<<(std::ostream &os, const JLEventlog &log) {
log.Dump(os); log.Dump(os);
return os; return os;
} }
class BXEXPORT JLEventlogEntry class BXEXPORT JLEventlogEntry
{ {
public: public:
typedef enum { typedef enum {
ALWAYS_LOG, JES_ALWAYS_LOG,
SEVERE_ERROR, JES_SEVERE_ERROR,
ERROR, JES_ERROR,
WARNING, JES_WARNING,
INFORMATION, JES_INFORMATION,
DEBUG_INFO JES_DEBUG_INFO
} Severity_t; } Severity_t;
typedef enum { typedef enum {
NUMBER = 1, JEVT_NUMBER = 1,
STRING, JEVT_STRING,
EXCEPTION JEVT_EXCEPTION
} ViewerType_t; } ViewerType_t;
std::string Guid; std::string Guid;
uint64_t MSTimestamp; // time_t in milliseconds uint64_t MSTimestamp; // time_t in milliseconds
Severity_t Severity; Severity_t Severity;
ViewerType_t Type; ViewerType_t Type;
std::string App; std::string App;
std::string Data; std::string Data;
protected: protected:
skipping to change at line 182 skipping to change at line 183
} }
unsigned int Major; unsigned int Major;
unsigned int Minor; unsigned int Minor;
unsigned int SubMinor; unsigned int SubMinor;
unsigned int Build; unsigned int Build;
}; };
public: public:
uint32_t HardwareId; uint32_t HardwareId;
uint32_t Pin; struct Pin Pin;
VersionQuad OsVersion; VersionQuad OsVersion;
VersionQuad VmVersion; VersionQuad VmVersion;
uint32_t RadioId; uint32_t RadioId;
uint32_t VendorId; uint32_t VendorId;
uint32_t ActiveWafs; uint32_t ActiveWafs;
Data OsMetrics; Data OsMetrics;
Data BootromMetrics; Data BootromMetrics;
public: public:
void Dump(std::ostream &os) const; void Dump(std::ostream &os) const;
 End of changes. 5 change blocks. 
11 lines changed or deleted 12 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 55 skipping to change at line 55
// when mode was selected // when mode was selected
public: public:
Mode(Controller &con, Controller::ModeType type); Mode(Controller &con, Controller::ModeType type);
virtual ~Mode(); virtual ~Mode();
////////////////////////////////// //////////////////////////////////
// primary operations - required before anything else // primary operations - required before anything else
void Open(const char *password = 0); void Open(const char *password = 0);
void Open(const char *password, const char *name);
void RetryPassword(const char *password); void RetryPassword(const char *password);
// void Close(); // void Close();
protected: protected:
////////////////////////////////// //////////////////////////////////
// overrides // overrides
virtual void OnOpen(); virtual void OnOpen();
}; };
 End of changes. 2 change blocks. 
1 lines changed or deleted 2 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2008-2011, 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 64 skipping to change at line 64
PppFilter m_filter; PppFilter m_filter;
// UsbSerData cache // UsbSerData cache
// Data m_readCache; // Data m_readCache;
// external callbacks // external callbacks
DeviceDataCallback m_callback; DeviceDataCallback m_callback;
void *m_callback_context; void *m_callback_context;
protected: protected:
static void DataCallback(void *context, Data *data); static void DataCallback(Serial &context, Data *data);
static void CtrlCallback(void *context, Data *data); static void CtrlCallback(Serial &context, Data *data);
public: public:
Serial(Controller &con, DeviceDataCallback callback, void *callback_ context); Serial(Controller &con, DeviceDataCallback callback, void *callback_ context);
~Serial(); ~Serial();
////////////////////////////////// //////////////////////////////////
// general operations // general operations
void Open(const char *password = 0); // FIXME password needed? i f not, void Open(const char *password = 0); // FIXME password needed? i f not,
// then we can remove it fro m // then we can remove it fro m
// the Modem base class // the Modem base class
 End of changes. 2 change blocks. 
3 lines changed or deleted 3 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2008-2011, 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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_PARSER_H__ #ifndef __BARRY_PARSER_H__
#define __BARRY_PARSER_H__ #define __BARRY_PARSER_H__
#include "dll.h" #include "dll.h"
#include "data.h" #include "data.h"
#include "protocol.h" #include "protocol.h"
#include <stdint.h> // for uint32_t #include <stdint.h> // for uint32_t
#include <iosfwd>
#include <map>
// forward declarations // forward declarations
namespace Barry { namespace Barry {
class Data;
class IConverter; class IConverter;
class Contact;
class Message;
class Calendar;
class CalendarAll;
class CallLog;
class Bookmark;
class ServiceBook;
class Memo;
class Task;
class PINMessage;
class SavedMessage;
class Sms;
class Folder;
class Timezone;
class ContentStore;
} }
//
// This macro can be used to automatically generate code for all known
// record types. Just #undef HANDLE_PARSER, then #define it to whatever
// you need, then use ALL_KNOWN_PARSER_TYPES. See parser.cc for
// various examples.
//
// These are sorted so their GetDBName()'s will display in alphabetical ord
er.
//
#define ALL_KNOWN_PARSER_TYPES \
HANDLE_PARSER(Contact) \
HANDLE_PARSER(Bookmark) \
HANDLE_PARSER(Calendar) \
HANDLE_PARSER(CalendarAll) \
HANDLE_PARSER(ContentStore) \
HANDLE_PARSER(Folder) \
HANDLE_PARSER(Memo) \
HANDLE_PARSER(Message) \
HANDLE_PARSER(CallLog) \
HANDLE_PARSER(PINMessage) \
HANDLE_PARSER(SavedMessage) \
HANDLE_PARSER(ServiceBook) \
HANDLE_PARSER(Sms) \
HANDLE_PARSER(Task) \
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
/// with the Packet class, calls each of the virtual functions below /// with the Packet class, calls each of the virtual functions below
skipping to change at line 58 skipping to change at line 99
/// This class is kept as a pure abstract class, in order to make sure /// This class is kept as a pure abstract class, in order to make sure
/// that the compiler will catch any API changes, for code derived /// that the compiler will catch any API changes, for code derived
/// from it. /// from it.
/// ///
class BXEXPORT Parser class BXEXPORT Parser
{ {
public: public:
Parser() {} Parser() {}
virtual ~Parser() {} virtual ~Parser() {}
/// Reset and prepare for a new raw data packet
virtual void Clear() = 0;
/// Stores the IDs
virtual void SetIds(uint8_t RecType, uint32_t UniqueId) = 0;
/// Called to parse the header portion of the raw data packet.
/// data contains the entire packet, and offset contains the
/// location at which to start parsing.
virtual void ParseHeader(const Data &data, size_t &offset) = 0;
/// Called to parse sub fields in the raw data packet. /// Called to parse sub fields in the raw data packet.
/// The same data is passed as was passed in ParseHeader, virtual void ParseRecord(const DBData &data, const IConverter *ic) =
/// only the offset will be updated if it was advanced during 0;
/// the header parsing.
virtual void ParseFields(const Data &data, size_t &offset,
const IConverter *ic) = 0;
/// Called at the very end of record parsing, and used to
/// store the final packet somewhere, either in memory, disk, etc.
virtual void Store() = 0;
}; };
// //
// NullParser class // NullParser class
// //
/// If in debug mode, this class can be used as a null parser. /// If in debug mode, this class can be used as a null parser.
/// Call Init() and the protocol will be dumped to stdout and /// Call Init() and the protocol will be dumped to stdout and
/// no parsing will be done. /// no parsing will be done.
/// ///
/// Do NOT derive your own personal parser classes from this, /// Do NOT derive your own personal parser classes from this,
/// unless you are perfectly confident that you will catch /// unless you are perfectly confident that you will catch
/// future API changes on the devel tree without the compiler's /// future API changes on the devel tree without the compiler's
/// help. /// help.
/// ///
class BXEXPORT NullParser : public Parser class BXEXPORT NullParser : public Parser
{ {
public: public:
NullParser() {} NullParser() {}
virtual ~NullParser() {} virtual ~NullParser() {}
/// Reset and prepare for a new raw data packet virtual void ParseRecord(const DBData &data, const IConverter *ic) {
virtual void Clear() {} }
};
/// Stores the IDs //
virtual void SetIds(uint8_t RecType, uint32_t UniqueId) {} // HexDumpParser
//
/// Dumps raw hex of the given DBData to the given stream.
///
/// Do NOT derive your own personal parser classes from this,
/// unless you are perfectly confident that you will catch
/// future API changes on the devel tree without the compiler's
/// help.
///
class BXEXPORT HexDumpParser : public Parser
{
std::ostream &m_os;
std::string m_last_dbname;
/// Called to parse the header portion of the raw data packet. public:
/// data contains the entire packet, and offset contains the explicit HexDumpParser(std::ostream &os);
/// location at which to start parsing.
virtual void ParseHeader(const Data &data, size_t &offset) {}
/// Called to parse sub fields in the raw data packet. virtual void ParseRecord(const Barry::DBData &data,
/// The same data is passed as was passed in ParseHeader, const IConverter *ic);
/// only the offset will be updated if it was advanced during };
/// the header parsing.
virtual void ParseFields(const Data &data, size_t &offset,
const IConverter *ic) {}
/// Called at the very end of record parsing, and used to //
/// store the final packet somewhere, either in memory, disk, etc. // RecordParserBase
virtual void Store() {} //
/// Abstract base class for the following RecordParser template, that expos
es
/// some information on the specifics that the record parser can handle.
/// Specifically, it exposes the database name it is able to parse
///
class BXEXPORT RecordParserBase : public Parser
{
public:
// These functions are always valid, regardless of the
// state of the parser.
virtual const char * GetDBName() const = 0;
virtual uint8_t GetDefaultRecType() const = 0;
// These functions depend on the parser having just parsed
// a record successfully.
virtual bool IsRecordValid() const = 0;
virtual uint8_t GetRecType() const = 0;
virtual uint32_t GetUniqueId() const = 0;
virtual void Dump(std::ostream &os) const = 0;
};
//
// Note: Store classes take parsed Record objects as a functor.
// Parser classes deal with raw data, while Store classes deal with
// parsed Record objects.
//
//
// NullStore
//
/// A Storage class for RecordParser<> that does nothing, for the cases
/// where you only want to dump parsed record data to a stream.
///
template <class RecordT>
class NullStore
{
public:
void operator() (const RecordT &r)
{
}
};
//
// DumpStore
//
/// A Storage class for RecordParser<> that dumps the parsed record data
/// to the given stream.
///
template <class RecordT>
class DumpStore
{
std::ostream &m_os;
public:
explicit DumpStore(std::ostream &os)
: m_os(os)
{
}
void operator() (const RecordT &r)
{
r.Dump(m_os);
}
}; };
// //
// ParseDBData
//
/// Contains the proper way to convert a DBData object into a record.
///
template <class RecordT>
void ParseDBData(const DBData &data, RecordT &rec, const IConverter *ic)
{
// start fresh
rec = RecordT();
// parse
rec.SetIds(data.GetRecType(), data.GetUniqueId());
size_t offset = data.GetOffset();
rec.ParseHeader(data.GetData(), offset);
rec.ParseFields(data.GetData(), offset, ic);
}
//
// RecordParser template class // RecordParser template class
// //
/// Template class for easy creation of specific parser objects. This temp late /// Template class for easy creation of specific parser objects. This temp late
/// takes the following template arguments: /// takes the following template arguments:
/// ///
/// - RecordT: One of the record parser classes in record.h /// - RecordT: One of the record parser classes in record.h
/// - StorageT: A custom storage functor class. An object of this type /// - StorageT: A custom storage functor class. An object of this type
/// will be called as a function with parsed Record as an /// will be called as a function with parsed Record as an
/// argument. This happens on the fly as the data is retrieved /// argument. This happens on the fly as the data is retrieved
/// from the device over USB, so it should not block forever. /// from the device over USB, so it should not block forever.
skipping to change at line 156 skipping to change at line 265
/// ///
/// Controller con(probeResult); /// Controller con(probeResult);
/// con.OpenMode(Controller::Desktop); /// con.OpenMode(Controller::Desktop);
/// std::vector<Contact> contactList; /// std::vector<Contact> contactList;
/// StoreContact storage(contactList); /// StoreContact storage(contactList);
/// RecordParser<Contact, StoreContact> parser(storage); /// RecordParser<Contact, StoreContact> parser(storage);
/// con.LoadDatabase(con.GetDBID("Address Book"), parser); /// con.LoadDatabase(con.GetDBID("Address Book"), parser);
/// </pre> /// </pre>
/// ///
template <class RecordT, class StorageT> template <class RecordT, class StorageT>
class RecordParser : public Parser class RecordParser : public RecordParserBase
{ {
StorageT *m_store; StorageT *m_store;
bool m_owned; bool m_owned;
RecordT m_rec; RecordT m_rec;
bool m_record_valid;
public: public:
/// Constructor that references an externally managed storage object . /// Constructor that references an externally managed storage object .
RecordParser(StorageT &storage) RecordParser(StorageT &storage)
: m_store(&storage), m_owned(false) {} : m_store(&storage)
, m_owned(false)
, m_record_valid(false)
{
}
/// Constructor that references a locally managed storage object. /// Constructor that references a locally managed storage object.
/// The pointer passed in will be stored, and freed when this class /// The pointer passed in will be stored, and freed when this class
/// is destroyed. It is safe to call this constructor with /// is destroyed. It is safe to call this constructor with
/// a 'new'ly created storage object. /// a 'new'ly created storage object.
RecordParser(StorageT *storage) RecordParser(StorageT *storage = 0)
: m_store(storage), m_owned(true) {} : m_store(storage)
, m_owned(true)
, m_record_valid(false)
{
}
~RecordParser() ~RecordParser()
{ {
if( this->m_owned ) if( this->m_owned )
delete m_store; delete m_store;
} }
virtual void Clear() virtual StorageT* GetStore()
{ {
m_rec = RecordT(); return m_store;
} }
virtual void SetIds(uint8_t RecType, uint32_t UniqueId) virtual const StorageT* GetStore() const
{ {
m_rec.SetIds(RecType, UniqueId); return m_store;
} }
virtual void ParseHeader(const Data &data, size_t &offset) virtual void ParseRecord(const DBData &data, const IConverter *ic)
{ {
m_rec.ParseHeader(data, offset); m_record_valid = false;
ParseDBData(data, m_rec, ic);
m_record_valid = true;
if( m_store )
(*m_store)(m_rec);
} }
virtual void ParseFields(const Data &data, size_t &offset, //
const IConverter *ic) // RecordParserBase overrides
//
// These functions are always valid, regardless of the
// state of the parser.
virtual const char * GetDBName() const
{ {
m_rec.ParseFields(data, offset, ic); return RecordT::GetDBName();
} }
virtual void Store() virtual uint8_t GetDefaultRecType() const
{
return RecordT::GetDefaultRecType();
}
// These functions depend on the parser having just parsed
// a record successfully.
virtual bool IsRecordValid() const
{
return m_record_valid;
}
virtual uint8_t GetRecType() const
{
return m_rec.GetRecType();
}
virtual uint32_t GetUniqueId() const
{
return m_rec.GetUniqueId();
}
virtual void Dump(std::ostream &os) const
{
m_rec.Dump(os);
}
};
//
// AllRecordStore
//
/// Base class with overloaded functor behaviour for all available
/// record classes. To be used with AllRecordParser.
///
class BXEXPORT AllRecordStore
{
public:
AllRecordStore() {}
virtual ~AllRecordStore() {}
#undef HANDLE_PARSER
#define HANDLE_PARSER(tname) \
virtual void operator() (const Barry::tname &) = 0;
ALL_KNOWN_PARSER_TYPES
};
//
// MultiRecordParser
//
/// Container parser class that accepts multiple Parser objects
/// (often RecordParser<> objects but they don't have to be) and
/// automatically routes incoming records to the appropriate parser.
/// Note that this container owns *all* Parser objects, and will
/// free them upon destruction.
///
/// Incoming records that have no matching parser are passed to the
/// default parser object, if one exists, otherwise they are dropped
/// silently. The default parser object is also owned by the container,
/// and will be freed on destruction.
///
/// Do NOT derive your own personal parser classes from this,
/// unless you are perfectly confident that you will catch
/// future API changes on the devel tree without the compiler's
/// help.
///
class BXEXPORT MultiRecordParser : public Parser
{
typedef std::map<std::string, Parser*> map_type;
Parser *m_delete_default; // if set, will be freed
Parser *m_default; // used by all code for actual work
// and may or may not be "owned" by
us
map_type m_parsers;
public:
// takes ownership of default_parser!
explicit MultiRecordParser(Parser *default_parser = 0);
// does not take ownership of the default_parser
explicit MultiRecordParser(Parser &default_parser);
~MultiRecordParser();
/// Adds given parser to list and takes ownership of it
void Add(const std::string &dbname, Parser *parser);
/// Adds given parser to list and takes ownership of it
void Add(RecordParserBase *parser);
/// Creates a RecordParser<> object using the given record
/// type and AllRecordStore. Does NOT take ownership of the
/// store object, since it can be used multiple times for
/// multiple records.
template <class RecordT>
void Add(AllRecordStore &store)
{
Add( RecordT::GetDBName(),
new RecordParser<RecordT, AllRecordStore>(store) );
}
/// Two helper template functions that create the RecordParser<>
/// automatically based on the function call. Both pointer and
/// reference versions.
template <class RecordT, class StorageT>
void Add(StorageT *store)
{
Add( RecordT::GetDBName(),
new RecordParser<RecordT, StorageT>(store) );
}
template <class RecordT, class StorageT>
void Add(StorageT &store)
{
Add( RecordT::GetDBName(),
new RecordParser<RecordT, StorageT>(store) );
}
/// Creates a RecordParser<> object for the given database name,
/// using DumpStore<> with the given stream for the output,
/// and adds it to list.
/// Returns false if there is no known Record class for dbname.
bool Add(const std::string &dbname, std::ostream &os);
/// Creates a RecordParser<> object for the given database name,
/// using the given store object.
/// Returns false if there is no known Record class for dbname.
bool Add(const std::string &dbname, AllRecordStore &store);
// Parser overrides
virtual void ParseRecord(const DBData &data, const IConverter *ic);
};
//
// AllRecordDumpStore
//
/// Derived from AllRecordStore, which just calls each record's
/// Dump() member with the given stream.
///
class BXEXPORT AllRecordDumpStore : public AllRecordStore
{
protected:
std::ostream &m_os;
public:
explicit AllRecordDumpStore(std::ostream &os)
: m_os(os)
{ {
(*m_store)(m_rec);
} }
#undef HANDLE_PARSER
#define HANDLE_PARSER(tname) \
virtual void operator() (const Barry::tname &);
ALL_KNOWN_PARSER_TYPES
};
//
// AllRecordParser
//
/// Convenience parser that creates a MultiRecordParser with all known
/// record parsers added. If an AllRecordStore pointer is passed in,
/// this class takes ownership of it, and uses it as the store object
/// for all the RecordParser<> objects it creates. If not, then
/// a custom DumpStore<> object is created with the given stream
/// for each RecordParser<> added.
///
/// The default parser object behaves just like MultiRecordParser
///
/// This class takes ownership of all pointers passed in.
///
class BXEXPORT AllRecordParser : public MultiRecordParser
{
AllRecordStore *m_store;
protected:
// does not take ownership of store, by itself,
// but the constructor that calls it might
void AddRecords(std::ostream *os, AllRecordStore *store);
public:
// takes ownership of default_parser and store!
explicit AllRecordParser(std::ostream &os,
Parser *default_parser = 0,
AllRecordStore *store = 0);
// does not take ownership of default_parser or store
AllRecordParser(Parser &default_parser, AllRecordStore &store);
~AllRecordParser();
};
//
// TeeParser
//
/// Sends incoming DBData objects to all the parsers in its list.
/// This parser container does NOT own the parsers added.
///
class BXEXPORT TeeParser : public Parser
{
typedef std::vector<Parser*> parser_list_type;
parser_list_type m_external_parsers, m_owned_parsers;
public:
TeeParser();
~TeeParser();
/// Adds parser to internal list, and takes ownership of the
/// pointer.
void Add(Parser *p);
/// Adds parser to internal list. Does NOT own the parser reference
.
void Add(Parser &p);
void ParseRecord(const DBData &data, const IConverter *ic);
}; };
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 28 change blocks. 
54 lines changed or deleted 400 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2008-2011, 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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_PROBE_H__ #ifndef __BARRY_PROBE_H__
#define __BARRY_PROBE_H__ #define __BARRY_PROBE_H__
#include "dll.h" #include "dll.h"
#include "usbwrap.h" #include "usbwrap.h"
#include "pin.h"
#include <vector> #include <vector>
#include <iosfwd> #include <iosfwd>
#include <stdint.h> #include <stdint.h>
namespace Barry { namespace Barry {
class Probe;
struct BXEXPORT ProbeResult struct BXEXPORT ProbeResult
{ {
friend class Probe;
Usb::DeviceIDType m_dev; Usb::DeviceIDType m_dev;
unsigned char m_interface; unsigned char m_interface;
uint32_t 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
// endpoints before using them. On some devices such
// as the 8830 it's essential to clear halt. On other
// devices such as the Curve 8520 calling clear halt
// can cause them to get into a state where they drop
// packets.
bool m_needClearHalt;
// Specifies if it's necessary to call usb_set_altinterface()
// before attempting to use the end points for this device.
//
// This can help to re-synchronize the state between the USB
// host and the device. However it can also cause usb-storage
// URBs to be lost on some device, so it's only used as a
// last resort.
bool m_needSetAltInterface;
uint8_t m_zeroSocketSequence; uint8_t m_zeroSocketSequence;
std::string m_description; std::string m_description;
// data from a possible ConfigFile (filled in automatically by
// the probe code if available)
std::string m_cfgDeviceName;
private:
// All ProbeResult objects should come from Probe, therefore
// this constructor is private to force the issue.
ProbeResult() ProbeResult()
: m_dev(0), m_interface(0), m_pin(0), m_zeroSocketSequence(0 : m_dev(0), m_interface(0), m_pin(0)
) , m_needClearHalt(false), m_needSetAltInterface(false)
, m_zeroSocketSequence(0)
{} {}
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(); }
bool operator==(const Barry::Pin &pin) const
{
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
{ {
std::vector<ProbeResult> m_results; public:
typedef std::vector<ProbeResult> Results;
private:
Results m_results;
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::DeviceIDType devid);
void ProbeDeviceEndpoints(Usb::Device &dev, Usb::EndpointDiscovery & ed, 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 uint32_t &pin, std::string &desc, uint8_t &zeroSocketSequenc
e); e,
bool &needClearHalt);
bool ProbeModem(Usb::Device &dev, const Usb::EndpointPair &ep); bool ProbeModem(Usb::Device &dev, const Usb::EndpointPair &ep);
public: public:
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);
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[ const std::string& GetFailMsg(int index) const { return m_fail_msgs.
index]; } at(index); }
const ProbeResult& Get(int index) const { return m_results[index]; } const ProbeResult& Get(int index) const { return m_results.at(index)
; }
int FindActive(uint32_t pin = 0) const; // returns -1 if pin not fou nd int FindActive(Barry::Pin pin = 0) const; // returns -1 if pin not f ound
// or if no devices // or if no devices
static int FindActive(const Results &results, Barry::Pin pin = 0);
static int Find(const Results &results, Barry::Pin pin = 0);
}; };
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 17 change blocks. 
11 lines changed or deleted 57 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 34 skipping to change at line 34
// packet commands (Packet.command: has response codes too) // packet commands (Packet.command: has response codes too)
#define SB_COMMAND_ECHO 0x01 #define SB_COMMAND_ECHO 0x01
#define SB_COMMAND_ECHO_REPLY 0x02 #define SB_COMMAND_ECHO_REPLY 0x02
#define SB_COMMAND_RESET 0x03 #define SB_COMMAND_RESET 0x03
#define SB_COMMAND_RESET_REPLY 0x04 #define SB_COMMAND_RESET_REPLY 0x04
#define SB_COMMAND_FETCH_ATTRIBUTE 0x05 #define SB_COMMAND_FETCH_ATTRIBUTE 0x05
#define SB_COMMAND_FETCHED_ATTRIBUTE 0x06 #define SB_COMMAND_FETCHED_ATTRIBUTE 0x06
#define SB_COMMAND_SELECT_MODE 0x07 #define SB_COMMAND_SELECT_MODE 0x07
#define SB_COMMAND_MODE_SELECTED 0x08 #define SB_COMMAND_MODE_SELECTED 0x08
#define SB_COMMAND_MODE_NOT_SELECTED 0x09
#define SB_COMMAND_OPEN_SOCKET 0x0a #define SB_COMMAND_OPEN_SOCKET 0x0a
#define SB_COMMAND_CLOSE_SOCKET 0x0b #define SB_COMMAND_CLOSE_SOCKET 0x0b
#define SB_COMMAND_CLOSED_SOCKET 0x0c #define SB_COMMAND_CLOSED_SOCKET 0x0c
#define SB_COMMAND_REMOTE_CLOSE_SOCKET 0x0d
#define SB_COMMAND_PASSWORD_CHALLENGE 0x0e #define SB_COMMAND_PASSWORD_CHALLENGE 0x0e
#define SB_COMMAND_PASSWORD 0x0f #define SB_COMMAND_PASSWORD 0x0f
#define SB_COMMAND_OPENED_SOCKET 0x10 #define SB_COMMAND_OPENED_SOCKET 0x10
#define SB_COMMAND_PASSWORD_FAILED 0x11 #define SB_COMMAND_PASSWORD_FAILED 0x11
#define SB_COMMAND_SEQUENCE_HANDSHAKE 0x13 #define SB_COMMAND_SEQUENCE_HANDSHAKE 0x13
#define SB_COMMAND_DB_DATA 0x40 #define SB_COMMAND_DB_DATA 0x40
#define SB_COMMAND_DB_FRAGMENTED 0x60 #define SB_COMMAND_DB_FRAGMENTED 0x60
#define SB_COMMAND_DB_DONE 0x41 #define SB_COMMAND_DB_DONE 0x41
// JavaLoader commands // JavaLoader commands
skipping to change at line 81 skipping to change at line 83
#define SB_COMMAND_JL_WIPE_FS 0x6b #define SB_COMMAND_JL_WIPE_FS 0x6b
#define SB_COMMAND_JL_LOG_STRACES 0x8e #define SB_COMMAND_JL_LOG_STRACES 0x8e
#define SB_COMMAND_JL_RESET_FACTORY 0x91 #define SB_COMMAND_JL_RESET_FACTORY 0x91
// JavaLoader response // JavaLoader response
#define SB_COMMAND_JL_ACK 0x64 #define SB_COMMAND_JL_ACK 0x64
#define SB_COMMAND_JL_READY 0x01 #define SB_COMMAND_JL_READY 0x01
#define SB_COMMAND_JL_RESET_REQUIRED 0x78 // Occurs after GOODBYE when handheld reset is required #define SB_COMMAND_JL_RESET_REQUIRED 0x78 // Occurs after GOODBYE when handheld reset is required
#define SB_COMMAND_JL_COD_IN_USE 0x6c // Perhaps "BUSY" is also a good name? #define SB_COMMAND_JL_COD_IN_USE 0x6c // Perhaps "BUSY" is also a good name?
#define SB_COMMAND_JL_COD_NOT_FOUND 0x69 #define SB_COMMAND_JL_COD_NOT_FOUND 0x69
#define SB_COMMAND_JL_NOT_ENOUGH_MEMORY 0x6a // Occurs when the internal memory isn't enough to install the new COD file
#define SB_COMMAND_JL_NOT_SUPPORTED 0x71 // Occurs when device does n ot support a command #define SB_COMMAND_JL_NOT_SUPPORTED 0x71 // Occurs when device does n ot support a command
// JavaLoader data // JavaLoader data
#define SB_DATA_JL_SUCCESS 0x64 // Device has accepted the d ata packet #define SB_DATA_JL_SUCCESS 0x64 // Device has accepted the d ata packet
#define SB_DATA_JL_INVALID 0x68 // Device returns this code if the application isn't valid. #define SB_DATA_JL_INVALID 0x68 // Device returns this code if the application isn't valid.
// JDWP Command set list // JDWP Command set list
#define JDWP_CMDSET_VIRTUALMACHINE 1 #define JDWP_CMDSET_VIRTUALMACHINE 1
#define JDWP_CMDSET_REFERECENTYPE 2 #define JDWP_CMDSET_REFERECENTYPE 2
#define JDWP_CMDSET_CLASSTYPE 3 #define JDWP_CMDSET_CLASSTYPE 3
 End of changes. 4 change blocks. 
1 lines changed or deleted 4 lines changed or added


 r_calendar.h   r_calendar.h 
/// ///
/// \file r_calendar.h /// \file r_calendar.h
/// Blackberry database record parser class for calndar records. /// Blackberry database record parser class for calendar records .
/// ///
/* /*
Copyright (C) 2005-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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
// 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 Calendar : public RecurBase class BXEXPORT Calendar : public RecurBase
{ {
public: public:
typedef std::vector<UnknownField> 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 time_t NotificationTime; // 0 means notification is off
skipping to change at line 100 skipping to change at line 100
/// RFC2445 CLASS is PUBLIC, PRIVATE, CONFIDENTIAL /// RFC2445 CLASS is PUBLIC, PRIVATE, CONFIDENTIAL
/// ///
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)
unsigned short TimeZoneCode; // the time zone originally used unsigned short 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
// 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);
virtual void DumpSpecialFields(std::ostream &os) const;
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)
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)
void Clear(); void Clear();
void Dump(std::ostream &os) const; void Dump(std::ostream &os) const;
std::string GetDescription() const;
// sorting // sorting
bool operator<(const Calendar &other) const { return StartTime < oth er.StartTime; } 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?
}; };
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
{
protected:
virtual void DumpSpecialFields(std::ostream &os) const;
public:
std::string MailAccount;
public:
// Parser / Builder API (see parser.h / builder.h)
void ParseHeader(const Data &data, size_t &offset);
void Clear();
public:
// database name
static const char * GetDBName() { return "Calendar - All"; }
};
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CalendarAl
l &msg) {
msg.Dump(os);
return os;
}
/// @} /// @}
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 10 change blocks. 
5 lines changed or deleted 36 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 {
// forward declarations // forward declarations
class IConverter; class IConverter;
class BXEXPORT CallLog class BXEXPORT CallLog
{ {
public: public:
typedef std::vector<UnknownField> UnknownsType; typedef Barry::UnknownsType UnknownsType;
uint8_t RecType; uint8_t RecType;
uint32_t RecordId; uint32_t RecordId;
uint32_t Duration; //< duration of call in seconds uint32_t Duration; //< duration of call in seconds
uint64_t Timestamp; //< timestamp of call in millisecond s uint64_t Timestamp; //< timestamp of call in millisecond s
//< use GetTime() to convert to //< use GetTime() to convert to
//< a time_t //< a time_t
std::string ContactName; std::string ContactName;
std::string PhoneNumber; std::string PhoneNumber;
skipping to change at line 117 skipping to change at line 117
~CallLog(); ~CallLog();
// Parser / Builder API (see parser.h / builder.h) // Parser / Builder API (see parser.h / builder.h)
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 BuildFields(Data &data, size_t &offset, const IConverter *ic =
0) const;
// 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;
// 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; }
}; };
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CallLog &m sg) { BXEXPORT inline std::ostream& operator<<(std::ostream &os, const CallLog &m sg) {
 End of changes. 6 change blocks. 
3 lines changed or deleted 7 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 68 skipping to change at line 68
// Contact record class // Contact record class
// //
/// 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 std::vector<UnknownField> UnknownsType; typedef Barry::UnknownsType UnknownsType;
typedef std::string EmailType; typedef std::string EmailType;
typedef std::vector<EmailType> EmailList; typedef std::vector<EmailType> EmailList;
// //
// Record fields // Record fields
// //
// contact specific data // contact specific data
uint8_t RecType; uint8_t RecType;
uint32_t RecordId; uint32_t RecordId;
skipping to change at line 92 skipping to change at line 92
/// to write to this field to the Blackberry, /// to write to this field to the Blackberry,
/// but modern devices won't let you add it /// but modern devices won't let you add it
/// through their GUIs. This field only seems /// through their GUIs. This field only seems
/// to exist on the 7750. While other devices /// to exist on the 7750. While other devices
/// accept the field and display it, it is /// accept the field and display it, it is
/// not accessible by default. /// not accessible by default.
std::string Phone; std::string Phone;
std::string std::string
Fax, Fax,
HomeFax,
WorkPhone, WorkPhone,
HomePhone, HomePhone,
MobilePhone, MobilePhone,
MobilePhone2,
Pager, Pager,
PIN, PIN,
Radio, Radio,
WorkPhone2, WorkPhone2,
HomePhone2, HomePhone2,
OtherPhone, OtherPhone,
FirstName, FirstName,
LastName, LastName,
Company, Company,
DefaultCommunicationsMethod, DefaultCommunicationsMethod,
JobTitle, JobTitle,
PublicKey, PublicKey,
URL, URL,
Prefix, Prefix,
Notes, Notes,
UserDefined1, UserDefined1,
UserDefined2, UserDefined2,
UserDefined3, UserDefined3,
UserDefined4, UserDefined4,
Image; Image,
Nickname;
Date Birthday; Date Birthday;
Date Anniversary; Date Anniversary;
PostalAddress WorkAddress; PostalAddress WorkAddress;
PostalAddress HomeAddress; PostalAddress HomeAddress;
// Categories are not allowed to have commas in them. // Categories are not allowed to have commas in them.
// A category name containing a comma will be split into // A category name containing a comma will be split into
// two categories, not only by this library, but by the // two categories, not only by this library, but by the
skipping to change at line 155 skipping to change at line 158
// Parser / Builder API (see parser.h / builder.h) // Parser / Builder API (see parser.h / builder.h)
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)
void Clear(); // erase everything void Clear(); // erase everything
void Dump(std::ostream &os) const; void Dump(std::ostream &os) const;
std::string GetDescription() const;
// sorting - put group links at the end // Sorting - use enough data to make the sorting as
bool operator<(const Contact &other) const { // consistent as possible
return GroupLinks.size() == 0 && other.GroupLinks.size() > 0 bool operator<(const Contact &other) const;
;
// // testing - put group links at the top
// return GroupLinks.size() > 0 && other.GroupLinks.size() == 0
;
}
// 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);
}; };
BXEXPORT inline std::ostream& operator<< (std::ostream &os, const Contact & contact) { BXEXPORT inline std::ostream& operator<< (std::ostream &os, const Contact & contact) {
 End of changes. 9 change blocks. 
12 lines changed or deleted 11 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 40 skipping to change at line 40
#include <stdint.h> #include <stdint.h>
namespace Barry { namespace Barry {
// forward declarations // forward declarations
class IConverter; class IConverter;
class BXEXPORT Folder class BXEXPORT Folder
{ {
public: public:
typedef std::vector<UnknownField> UnknownsType typedef Barry::UnknownsType UnknownsType;
;
uint8_t RecType; uint8_t RecType;
uint32_t RecordId; uint32_t RecordId;
std::string Name; std::string Name;
uint16_t Number; // Not unique, used for ordering of subfolde rs - NOT level uint16_t Number; // Not unique, used for ordering of subfolde rs - NOT level
uint16_t Level; // From parent uint16_t Level; // From parent
enum FolderType { enum FolderType {
FolderSubtree = 0, FolderSubtree = 0,
FolderDeleted, FolderDeleted,
skipping to change at line 83 skipping to change at line 84
~Folder(); ~Folder();
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;
// 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;
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; }
}; };
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);
 End of changes. 6 change blocks. 
4 lines changed or deleted 7 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 40 skipping to change at line 40
#include <stdint.h> #include <stdint.h>
namespace Barry { namespace Barry {
// forward declarations // forward declarations
class IConverter; class IConverter;
class BXEXPORT Memo class BXEXPORT Memo
{ {
public: public:
typedef std::vector<UnknownField> UnknownsType; typedef Barry::UnknownsType UnknownsType;
uint8_t RecType; uint8_t RecType;
uint32_t RecordId; uint32_t RecordId;
std::string Title; std::string Title;
std::string Body; std::string Body;
CategoryList Categories; CategoryList Categories;
UnknownsType Unknowns; UnknownsType Unknowns;
skipping to change at line 68 skipping to change at line 68
// Parser / Builder API (see parser.h / builder.h) // Parser / Builder API (see parser.h / builder.h)
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)
void Clear(); void Clear();
void Dump(std::ostream &os) const; void Dump(std::ostream &os) const;
std::string GetDescription() const;
bool operator<(const Memo &other) const;
bool operator<(const Memo &other) const { return Title < other.Title ; }
// 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?
}; };
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;
} }
 End of changes. 6 change blocks. 
4 lines changed or deleted 6 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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:
void Clear()
{
MessageBase::Clear();
RecType = GetDefaultRecType();
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; }
}; };
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;
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 9 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 47 skipping to change at line 47
class IConverter; class IConverter;
// //
// 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.
// //
class BXEXPORT MessageBase class BXEXPORT MessageBase
{ {
public: public:
typedef Barry::UnknownsType UnknownsType;
uint8_t RecType; uint8_t RecType;
uint32_t RecordId; uint32_t RecordId;
EmailAddressList From; EmailAddressList From;
EmailAddressList To; EmailAddressList To;
EmailAddressList Cc; EmailAddressList Cc;
EmailAddressList Bcc; EmailAddressList Bcc;
EmailAddressList Sender; //< not available for PINMes sage? EmailAddressList Sender; //< not available for PINMes sage?
EmailAddressList ReplyTo; //< not available for PINMes sage? EmailAddressList ReplyTo; //< not available for PINMes sage?
std::string Subject; std::string Subject;
skipping to change at line 95 skipping to change at line 97
enum SensitivityType { enum SensitivityType {
NormalSensitivity = 0, NormalSensitivity = 0,
Personal, Personal,
Private, Private,
Confidential, Confidential,
UnknownSensitivity UnknownSensitivity
}; };
SensitivityType Sensitivity; SensitivityType Sensitivity;
std::vector<UnknownField> Unknowns; UnknownsType Unknowns;
protected: protected:
std::string SimpleFromAddress() const; std::string SimpleFromAddress() const;
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();
skipping to change at line 118 skipping to change at line 120
public: public:
// Parser / Builder API (see parser.h / builder.h) // Parser / Builder API (see parser.h / builder.h)
uint8_t GetRecType() const; uint8_t GetRecType() const;
uint32_t GetUniqueId() const; // empty API, not required by protoc ol uint32_t GetUniqueId() const; // empty API, not required by protoc ol
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)
void Clear(); void Clear();
void Dump(std::ostream &os) const; void Dump(std::ostream &os) const;
std::string GetDescription() const;
// sorting // sorting
bool operator<(const MessageBase &other) const bool operator<(const MessageBase &other) const;
{
return Subject < other.Subject;
}
}; };
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const MessageBas e &msg) { BXEXPORT inline std::ostream& operator<<(std::ostream &os, const MessageBas e &msg) {
msg.Dump(os); msg.Dump(os);
return os; return os;
} }
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 7 change blocks. 
7 lines changed or deleted 7 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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:
void Clear()
{
MessageBase::Clear();
RecType = GetDefaultRecType();
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; }
}; };
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;
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 9 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 103 skipping to change at line 103
#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();
~RecurBase(); virtual ~RecurBase();
public: public:
// 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;
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 r_saved_message.h   r_saved_message.h 
/// ///
/// \file r_save_message.h /// \file r_save_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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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:
void Clear()
{
MessageBase::Clear();
RecType = GetDefaultRecType();
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; }
}; };
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;
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 9 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 52 skipping to change at line 52
// //
/// \addtogroup RecordParserClasses /// \addtogroup RecordParserClasses
/// @{ /// @{
// This is a packed field, which is a group of fields packed in // This is a packed field, which is a group of fields packed in
// variable length records inside one larger field of a normal record. // variable length records inside one larger field of a normal record.
class BXEXPORT ServiceBookConfig class BXEXPORT ServiceBookConfig
{ {
public: public:
typedef std::vector<UnknownField> UnknownsType; typedef Barry::UnknownsType UnknownsType;
uint8_t Format; uint8_t Format;
UnknownsType Unknowns; UnknownsType Unknowns;
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:
skipping to change at line 121 skipping to change at line 121
// Parser / Builder API (see parser.h / builder.h) // Parser / Builder API (see parser.h / builder.h)
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)
void Clear(); void Clear();
void Dump(std::ostream &os) const; void Dump(std::ostream &os) const;
std::string GetDescription() const;
// sorting // sorting
bool operator<(const ServiceBook &other) const { return RecordId < R ecordId; } 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; }
}; };
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;
} }
 End of changes. 6 change blocks. 
4 lines changed or deleted 5 lines changed or added


 r_sms.h   r_sms.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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 40 skipping to change at line 40
#include <stdint.h> #include <stdint.h>
namespace Barry { namespace Barry {
// forward declarations // forward declarations
class IConverter; class IConverter;
class BXEXPORT Sms class BXEXPORT Sms
{ {
public: public:
typedef std::vector<UnknownField> UnknownsType; typedef Barry::UnknownsType UnknownsType;
uint8_t RecType; uint8_t RecType;
uint32_t RecordId; uint32_t RecordId;
enum MessageType enum MessageType
{ {
Unknown = 0, Unknown = 0,
Received, Received,
Sent, Sent,
Draft Draft
skipping to change at line 102 skipping to change at line 102
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);
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;
// 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;
static std::string ConvertGsmToUtf8(const std::string &); static std::string ConvertGsmToUtf8(const std::string &);
// sorting - put group links at the end // 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; }
}; };
BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Sms &msg) { BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Sms &msg) {
 End of changes. 7 change blocks. 
4 lines changed or deleted 6 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 41 skipping to change at line 41
#include <stdint.h> #include <stdint.h>
namespace Barry { namespace Barry {
// forward declarations // forward declarations
class IConverter; class IConverter;
class BXEXPORT Task : public RecurBase class BXEXPORT Task : public RecurBase
{ {
public: public:
typedef std::vector<UnknownField> 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; time_t StartTime;
skipping to change at line 112 skipping to change at line 112
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;
// operations (common among record classes)
void Clear(); void Clear();
void Dump(std::ostream &os) const; void Dump(std::ostream &os) const;
bool operator<(const Task &other) const { return Summary < other.Sum std::string GetDescription() const;
mary; }
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; }
}; };
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;
 End of changes. 5 change blocks. 
5 lines changed or deleted 6 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 40 skipping to change at line 40
#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 std::vector<UnknownField> UnknownsType ; typedef Barry::UnknownsType UnknownsType;
uint8_t RecType; uint8_t RecType;
uint32_t RecordId; uint32_t RecordId;
uint8_t TZType; uint8_t TZType;
uint32_t DSTOffset; uint32_t DSTOffset;
int32_t Index; int32_t Index;
int32_t Offset; int32_t Offset;
int32_t OffsetFraction; int32_t OffsetFraction;
uint32_t StartMonth; uint32_t StartMonth;
skipping to change at line 74 skipping to change at line 74
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;
// 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;
bool operator<(const Timezone &other) const { return TimeZoneName < other.TimeZoneName; } bool operator<(const Timezone &other) const { return TimeZoneName < other.TimeZoneName; }
// 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; }
}; };
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;
 End of changes. 6 change blocks. 
3 lines changed or deleted 6 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 47 skipping to change at line 47
// 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.
// //
// stream-based wrapper to avoid printing strings that contain
// the \r carriage return characters
class BXEXPORT Cr2LfWrapper
{
friend std::ostream& operator<< (std::ostream &os, const Cr2LfWrappe
r &str);
const std::string &m_str;
public:
explicit Cr2LfWrapper(const std::string &str)
: m_str(str)
{
}
};
BXEXPORT std::ostream& operator<< (std::ostream &os, const Cr2LfWrapper &st
r);
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 156 skipping to change at line 170
const unsigned char* ParseField(const unsigned char *begin, const unsigned char* ParseField(const unsigned char *begin,
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();
// 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);
return os; return os;
skipping to change at line 183 skipping to change at line 199
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); }
}; };
struct BXEXPORT UnknownField struct BXEXPORT UnknownField
{ {
uint8_t type; uint8_t type;
UnknownData data; UnknownData data;
}; };
BXEXPORT std::ostream& operator<< (std::ostream &os, const std::vector<Unkn typedef std::vector<UnknownField> UnknownsType;
ownField> &unknowns); BXEXPORT std::ostream& operator<< (std::ostream &os, const UnknownsType &un
knowns);
struct BXEXPORT EmailAddress struct BXEXPORT EmailAddress
{ {
std::string Name; std::string Name;
std::string Email; std::string Email;
void clear() void clear()
{ {
Name.clear(); Name.clear();
Email.clear(); Email.clear();
skipping to change at line 280 skipping to change at line 297
/// RecordParser<> template when calling Controller::LoadDatabas e(). /// RecordParser<> template when calling Controller::LoadDatabas e().
/// @{ /// @{
/// @} /// @}
} // namespace Barry } // 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_contact.h" #include "r_contact.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"
#endif #endif
 End of changes. 6 change blocks. 
3 lines changed or deleted 24 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-2008, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 32 skipping to change at line 32
#ifndef __BARRY_ROUTER_H__ #ifndef __BARRY_ROUTER_H__
#define __BARRY_ROUTER_H__ #define __BARRY_ROUTER_H__
#include "dll.h" #include "dll.h"
#include <stdint.h> #include <stdint.h>
#include <map> #include <map>
#include <tr1/memory> #include <tr1/memory>
#include <stdexcept> #include <stdexcept>
#include <pthread.h> #include <pthread.h>
#include "dataqueue.h" #include "dataqueue.h"
#include "error.h"
namespace Usb { class Device; } #include "usbwrap.h"
namespace Barry { namespace Barry {
class DataHandle; class DataHandle;
class BXEXPORT SocketRoutingQueue class BXEXPORT SocketRoutingQueue
{ {
friend class DataHandle; friend class DataHandle;
public: public:
typedef void (*SocketDataHandler)(void *ctx, Data*); //< See Regi // Interface class for socket data callbacks
sterInterest() for information on this callback. // See RegisterInterest() for more information.
class BXEXPORT SocketDataHandler
{
public:
// Called when data is received on the socket
// for which interest has been registered.
//
// The lifetime of the data parameter is only valid
// for the duration of this method call.
virtual void DataReceived(Data& data) = 0;
// Called when an error has occured on the socket
// for which interest has been registered.
//
// The lifetime of the error parameter is only valid
// for the lifetime of this method call.
virtual void Error(Barry::Error &error);
virtual ~SocketDataHandler();
};
typedef std::tr1::shared_ptr<SocketDataHandler> SocketDataHandlerPtr
;
// Simple wrapper template class for SocketDataHandler which provide
s a basic data recieved callback
template<typename T> class SimpleSocketDataHandler : public SocketDa
taHandler
{
void (*m_callback)(T&, Data*);
T& m_context;
public:
SimpleSocketDataHandler<T>(T& context, void (*callback)(T& c
ontext, Data* data))
: m_callback(callback)
, m_context(context)
{}
virtual void DataReceived(Data& data)
{
m_callback(m_context, &data);
}
};
struct QueueEntry struct QueueEntry
{ {
SocketDataHandler m_handler; SocketDataHandlerPtr m_handler;
void *m_context;
DataQueue m_queue; DataQueue m_queue;
QueueEntry(SocketDataHandler h, void *c) QueueEntry(SocketDataHandlerPtr h)
: m_handler(h) : m_handler(h)
, m_context(c)
{} {}
}; };
typedef std::tr1::shared_ptr<QueueEntry> QueueEntryPtr; typedef std::tr1::shared_ptr<QueueEntry> QueueEntryPtr;
typedef uint16_t SocketId; typedef uint16_t SocketId;
typedef std::map<SocketId, QueueEntryPtr> SocketQueueMap; typedef std::map<SocketId, QueueEntryPtr> SocketQueueMap;
private: private:
Usb::Device * volatile m_dev; Usb::Device * volatile m_dev;
volatile int m_writeEp, m_readEp; volatile int m_writeEp, m_readEp;
volatile bool m_interest; // true if at least one socket has an inte rest. volatile bool m_interest; // true if at least one socket has an inte rest.
// used to optimize the reading // used to optimize the reading
mutable pthread_mutex_t m_mutex;// controls access to local data, bu t not mutable pthread_mutex_t m_mutex;// controls access to local data, bu t not
// DataQueues, as they have their own // DataQueues, as they have their own
// locking per queue // locking per queue
pthread_mutex_t m_readwaitMutex; pthread_mutex_t m_readwaitMutex;
pthread_cond_t m_readwaitCond; pthread_cond_t m_readwaitCond;
bool m_seen_usb_error;
SocketDataHandlerPtr m_usb_error_dev_callback;
DataQueue m_free; DataQueue m_free;
DataQueue m_default; DataQueue m_default;
SocketQueueMap m_socketQueues; SocketQueueMap m_socketQueues;
int m_timeout;
// thread state // thread state
pthread_t m_usb_read_thread; pthread_t m_usb_read_thread;
volatile bool m_continue_reading;// set to true when the thread is c reated, volatile bool m_continue_reading;// set to true when the thread is c reated,
// 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);
// 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);
public: public:
SocketRoutingQueue(int prealloc_buffer_count = 4); SocketRoutingQueue(int prealloc_buffer_count = 4,
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; }
// These functions connect the router to an external Usb::Device // These functions connect the router to an external Usb::Device
// object. Normally this is handled automatically by the // object. Normally this is handled automatically by the
// Controller class, but are public here in case they are needed. // Controller class, but are public here in case they are needed.
void SetUsbDevice(Usb::Device *dev, int writeEp, int readEp); //
// If DoRead encounters an error, it sets a flag and stops
// reading. To recover, you should handle the Error() call in
// the callback, fix the USB device, and then call
// ClearUsbError() to clear the flag.
//
void SetUsbDevice(Usb::Device *dev, int writeEp, int readEp,
SocketDataHandlerPtr callback = SocketDataHandlerPtr());
void ClearUsbDevice(); void ClearUsbDevice();
bool UsbDeviceReady(); bool UsbDeviceReady();
Usb::Device* GetUsbDevice() { return m_dev; } Usb::Device* GetUsbDevice() { return m_dev; }
void ClearUsbError();
// This class starts out with no buffers, and will grow one buffer // This class starts out with no buffers, and will grow one buffer
// at a time if needed. Call this to allocate count buffers // at a time if needed. Call this to allocate count buffers
// all at once and place them on the free queue. // all at once and place them on the free queue.
void AllocateBuffers(int count); void AllocateBuffers(int count);
// Returns the data for the next unregistered socket. // Returns the data for the next unregistered socket.
// Blocks until timeout or data is available. // Blocks until timeout or data is available.
// Returns false (or null pointer) on timeout and no data. // Returns false (or null pointer) on timeout and no data.
// With the return version of the function, there is no // With the return version of the function, there is no
// copying performed. // copying performed.
//
// Timeout is in milliseconds. Default timeout set by constructor
// is used if set to -1.
bool DefaultRead(Data &receive, int timeout = -1); bool DefaultRead(Data &receive, int timeout = -1);
DataHandle DefaultRead(int timeout = -1); DataHandle DefaultRead(int timeout = -1);
// Register an interest in data from a certain socket. To read // Register an interest in data from a certain socket. To read
// from that socket, use the SocketRead() function from then on. // from that socket, use the SocketRead() function from then on.
// Any non-registered socket goes in the default queue // Any non-registered socket goes in the default queue
// and must be read by DefaultRead() // and must be read by DefaultRead()
// If not null, handler is called when new data is read. It will // If not null, handler is called when new data is read. It will
// be called in the same thread instance that DoRead() is called fro m. // be called in the same thread instance that DoRead() is called fro m.
// Handler is passed the DataQueue Data pointer, and so no // Handler is passed the DataQueue Data object, and so no
// copying is done. Once the handler returns, the data is // copying is done. Once the handler returns, the data is
// considered processed and not added to the interested queue, // considered processed and not added to the interested queue,
// but instead returned to m_free. // but instead returned to m_free.
void RegisterInterest(SocketId socket, SocketDataHandler handler = 0 , void *context = 0); void RegisterInterest(SocketId socket, SocketDataHandlerPtr handler) ;
// Unregisters interest in data from the given socket, and discards // Unregisters interest in data from the given socket, and discards
// any existing data in its interest queue. Any new incoming data // any existing data in its interest queue. Any new incoming data
// for this socket will be placed in the default queue. // for this socket will be placed in the default queue.
void UnregisterInterest(SocketId socket); void UnregisterInterest(SocketId socket);
// Reads data from the interested socket cache. Can only read // Reads data from the interested socket cache. Can only read
// from sockets that have been previously registered. // from sockets that have been previously registered.
// Blocks until timeout or data is available. // Blocks until timeout or data is available.
// Returns false (or null pointer) on timeout and no data. // Returns false (or null pointer) on timeout and no data.
// With the return version of the function, there is no // With the return version of the function, there is no
// copying performed. // copying performed.
//
// Timeout is in milliseconds. Default timeout set by constructor
// is used if set to -1.
bool SocketRead(SocketId socket, Data &receive, int timeout = -1); bool SocketRead(SocketId socket, Data &receive, int timeout = -1);
DataHandle SocketRead(SocketId socket, int timeout = -1); DataHandle SocketRead(SocketId socket, int timeout = -1);
// Returns true if data is available for that socket. // Returns true if data is available for that socket.
bool IsAvailable(SocketId socket) const; bool IsAvailable(SocketId socket) const;
// Called by the application's "read thread" to read the next usb // Called by the application's "read thread" to read the next usb
// packet and route it to the correct queue. Returns after every // packet and route it to the correct queue. Returns after every
// read, even if a handler is associated with a queue. // read, even if a handler is associated with a queue.
// Note: this function is safe to call before SetUsbDevice() is // Note: this function is safe to call before SetUsbDevice() is
// called... it just doesn't do anything if there is no usb // called... it just doesn't do anything if there is no usb
// device to work with. // device to work with.
// //
// Timeout is in milliseconds. // Timeout is in milliseconds. Default is default USB timeout.
// void DoRead(int timeout = -1);
// Returns false in the case of USB errors, and puts the error
// message in msg.
bool DoRead(std::string &msg, int timeout = -1);
// Utility function to make it easier for the user to create the // Utility function to make it easier for the user to create the
// USB pure-read thread. If the user wants anything more complicate d // USB pure-read thread. If the user wants anything more complicate d
// in this background thread, he can implement it himself and call // in this background thread, he can implement it himself and call
// the above DoRead() in a loop. If only the basics are needed, // the above DoRead() in a loop. If only the basics are needed,
// then this makes it easy. // then this makes it easy.
// Throws Barry::ErrnoError on thread creation error. // Throws Barry::ErrnoError on thread creation error.
void SpinoffSimpleReadThread(); void SpinoffSimpleReadThread();
}; };
 End of changes. 16 change blocks. 
18 lines changed or deleted 74 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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_S11N_BOOST_H__ #ifndef __BARRY_S11N_BOOST_H__
#define __BARRY_S11N_BOOST_H__ #define __BARRY_S11N_BOOST_H__
#include "dll.h"
#include "record.h" #include "record.h"
#include <boost/serialization/vector.hpp> #include <boost/serialization/vector.hpp>
/////////////////////////////////////////////////////////////////////////// //// /////////////////////////////////////////////////////////////////////////// ////
// special versions // special versions
// //
// BARRY_BASE_S11N_VERSION - the base version where all record data is // BARRY_BASE_S11N_VERSION - the base version where all record data is
// stored so it can be fully retrieved and // stored so it can be fully retrieved and
// uploaded to the handheld device later. // uploaded to the handheld device later.
// BARRY_POD_MAP_VERSION - if these templates are called with a vers ion // BARRY_POD_MAP_VERSION - if these templates are called with a vers ion
skipping to change at line 78 skipping to change at line 79
template <class ArchiveT> 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("WorkPhone", c.WorkPhone); ar & make_nvp("WorkPhone", c.WorkPhone);
ar & make_nvp("HomePhone", c.HomePhone); ar & make_nvp("HomePhone", c.HomePhone);
ar & make_nvp("MobilePhone", c.MobilePhone); ar & make_nvp("MobilePhone", c.MobilePhone);
ar & make_nvp("MobilePhone2", c.MobilePhone2);
ar & make_nvp("Pager", c.Pager); ar & make_nvp("Pager", c.Pager);
ar & make_nvp("PIN", c.PIN); ar & make_nvp("PIN", c.PIN);
ar & make_nvp("Radio", c.Radio); ar & make_nvp("Radio", c.Radio);
ar & make_nvp("WorkPhone2", c.WorkPhone2); ar & make_nvp("WorkPhone2", c.WorkPhone2);
ar & make_nvp("HomePhone2", c.HomePhone2); ar & make_nvp("HomePhone2", c.HomePhone2);
ar & make_nvp("OtherPhone", c.OtherPhone); ar & make_nvp("OtherPhone", c.OtherPhone);
ar & make_nvp("FirstName", c.FirstName); ar & make_nvp("FirstName", c.FirstName);
ar & make_nvp("LastName", c.LastName); ar & make_nvp("LastName", c.LastName);
ar & make_nvp("Company", c.Company); ar & make_nvp("Company", c.Company);
ar & make_nvp("DefaultCommunicationsMethod", c.DefaultCommunications Method); ar & make_nvp("DefaultCommunicationsMethod", c.DefaultCommunications Method);
skipping to change at line 116 skipping to change at line 119
ar & make_nvp("Notes", c.Notes); ar & make_nvp("Notes", c.Notes);
ar & make_nvp("UserDefined1", c.UserDefined1); ar & make_nvp("UserDefined1", c.UserDefined1);
ar & make_nvp("UserDefined2", c.UserDefined2); ar & make_nvp("UserDefined2", c.UserDefined2);
ar & make_nvp("UserDefined3", c.UserDefined3); ar & make_nvp("UserDefined3", c.UserDefined3);
ar & make_nvp("UserDefined4", c.UserDefined4); ar & make_nvp("UserDefined4", c.UserDefined4);
ar & make_nvp("HomeCity", c.HomeAddress.City); ar & make_nvp("HomeCity", c.HomeAddress.City);
ar & make_nvp("HomeProvince", c.HomeAddress.Province); ar & make_nvp("HomeProvince", c.HomeAddress.Province);
ar & make_nvp("HomePostalCode", c.HomeAddress.PostalCode); ar & make_nvp("HomePostalCode", c.HomeAddress.PostalCode);
ar & make_nvp("HomeCountry", c.HomeAddress.Country); ar & make_nvp("HomeCountry", c.HomeAddress.Country);
ar & make_nvp("Image", c.Image); ar & make_nvp("Image", c.Image);
ar & make_nvp("Nickname", c.Nickname);
if( ver < BARRY_POD_MAP_VERSION ) { if( ver < BARRY_POD_MAP_VERSION ) {
ar & make_nvp("GroupLinks", c.GroupLinks); ar & make_nvp("GroupLinks", c.GroupLinks);
ar & make_nvp("Unknowns", c.Unknowns); ar & make_nvp("Unknowns", c.Unknowns);
} }
} }
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 )
{ {
skipping to change at line 188 skipping to change at line 192
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);
ar & make_nvp("Perpetual", c.Perpetual); ar & make_nvp("Perpetual", c.Perpetual);
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);
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> template <class ArchiveT>
void serialize(ArchiveT &ar, Barry::CalendarAll &c, const unsigned int ver)
{
serialize(ar, static_cast<Barry::Calendar&>(c), ver);
ar & make_nvp("MailAccount", c.MailAccount);
}
template <class ArchiveT>
void serialize(ArchiveT &ar, Barry::CallLog &c, const unsigned int ver) void serialize(ArchiveT &ar, Barry::CallLog &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("Duration", c.Duration); ar & make_nvp("Duration", c.Duration);
ar & make_nvp("Timestamp", c.Timestamp); ar & make_nvp("Timestamp", c.Timestamp);
ar & make_nvp("ContactName", c.ContactName); ar & make_nvp("ContactName", c.ContactName);
ar & make_nvp("PhoneNumber", c.PhoneNumber); ar & make_nvp("PhoneNumber", c.PhoneNumber);
skipping to change at line 224 skipping to change at line 237
ar & make_nvp("StatusFlag", c.StatusFlag); ar & make_nvp("StatusFlag", c.StatusFlag);
ar & make_nvp("PhoneTypeFlag", c.PhoneTypeFlag); ar & make_nvp("PhoneTypeFlag", c.PhoneTypeFlag);
ar & make_nvp("PhoneInfoFlag", c.PhoneInfoFlag); ar & make_nvp("PhoneInfoFlag", c.PhoneInfoFlag);
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> template <class ArchiveT>
void serialize(ArchiveT &ar, Barry::Bookmark &c, const unsigned int ver)
{
ar & make_nvp("RecType", c.RecType);
ar & make_nvp("RecordId", c.RecordId);
ar & make_nvp("Index", c.Index);
ar & make_nvp("Name", c.Name);
ar & make_nvp("Icon", c.Icon);
ar & make_nvp("Url", c.Url);
ar & make_nvp("BrowserIdentity", c.BrowserIdentity);
ar & make_nvp("DisplayMode", c.DisplayMode);
ar & make_nvp("JavaScriptMode", c.JavaScriptMode);
if( ver < BARRY_POD_MAP_VERSION ) {
ar & make_nvp("Unknowns", c.Unknowns);
}
}
template <class ArchiveT>
void serialize(ArchiveT &ar, Barry::ServiceBookConfig &c, const unsigned in t ver) void serialize(ArchiveT &ar, Barry::ServiceBookConfig &c, const unsigned in t ver)
{ {
ar & make_nvp("Format", c.Format); ar & make_nvp("Format", c.Format);
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> template <class ArchiveT>
skipping to change at line 440 skipping to change at line 473
ar & make_nvp("Left", t.Left); ar & make_nvp("Left", t.Left);
ar & make_nvp("UseDST", t.UseDST); ar & make_nvp("UseDST", t.UseDST);
ar & make_nvp("TimeZoneName", t.TimeZoneName); ar & make_nvp("TimeZoneName", t.TimeZoneName);
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>
void serialize(ArchiveT &ar, Barry::ContentStore &c, const unsigned int ver
)
{
ar & make_nvp("RecType", c.RecType);
ar & make_nvp("RecordId", c.RecordId);
ar & make_nvp("Filename", c.Filename);
ar & make_nvp("FolderFlag", c.FolderFlag);
ar & make_nvp("FileContent", c.FileContent);
ar & make_nvp("FileDescriptor", c.FileDescriptor);
// FileSize is not used for building, so no need to save it here
if( ver < BARRY_POD_MAP_VERSION ) {
ar & make_nvp("Unknowns", c.Unknowns);
}
}
}} // namespace boost::serialization }} // namespace boost::serialization
///////////////////////////////////////////////////////////////////////////
///
// Helper wrapper templates for loading and saving records to an iostream
namespace Barry {
// Can be used as a Storage class for RecordBuilder<>
template <class RecordT>
class BoostLoader
{
public:
typedef RecordT rec_type;
typedef std::vector<rec_type> list_type;
private:
list_type m_records;
typename list_type::iterator rec_it;
public:
explicit BoostLoader(std::istream &is)
{
boost::archive::text_iarchive ia(is);
ia >> m_records;
rec_it = m_records.begin();
}
list_type& GetRecords() { return m_records; }
const list_type& GetRecords() const { return m_records; }
// retrieval operator
bool operator()(RecordT &rec, Builder &builder)
{
if( rec_it == m_records.end() )
return false;
rec = *rec_it;
++rec_it;
return true;
}
};
// Can be used as a Storage class for RecordParser<>
template <class RecordT>
class BoostSaver
{
public:
typedef RecordT rec_type;
typedef std::vector<rec_type> list_type;
private:
std::ostream &m_os;
list_type m_records;
typename list_type::iterator rec_it;
public:
explicit BoostSaver(std::ostream &os)
: m_os(os)
{
}
~BoostSaver()
{
WriteArchive();
}
void WriteArchive() const
{
// write dbname first, so parsing is possible
m_os << RecordT::GetDBName() << std::endl;
// write boost archive of all records
boost::archive::text_oarchive oa(m_os);
// boost is fussy that the vector must be const
// we do this explicitly, for documentation's sake
const list_type &recs = m_records;
oa << recs;
m_os << std::endl;
}
list_type& GetRecords() { return m_records; }
const list_type& GetRecords() const { return m_records; }
// storage operator
void operator()(const RecordT &rec)
{
m_records.push_back(rec);
}
};
//
// BoostParser
//
/// This Parser turns incoming records (which can be of any record type
/// included in ALL_KNOWN_PARSER_TYPES) into a Boost Serialization stream
/// on the given iostream.
///
/// This class is defined completely in the header, so that it is
/// optional for applications to link against the boost libraries.
///
class BXEXPORT BoostParser : public Barry::Parser
{
std::auto_ptr<Barry::Parser> m_parser;
std::ofstream *m_ofs;
std::ostream &m_os; // references either an external object,
// or *m_ifs... this is the reference to
// use in the entire class... the constructo
r
// sets it up
std::string m_current_db;
public:
explicit BoostParser(const std::string &filename)
: m_ofs( new std::ofstream(filename.c_str()) )
, m_os(*m_ofs)
{
}
explicit BoostParser(std::ostream &os)
: m_ofs(0)
, m_os(os)
{
}
~BoostParser()
{
// flush any remaining parser output
// (note this still potentially uses m_ofs, so do this first
)
m_parser.reset();
// cleanup the stream
delete m_ofs;
}
void StartDB(const std::string &dbname)
{
// done with current parser, flush it's output
m_parser.reset();
#undef HANDLE_PARSER
#define HANDLE_PARSER(tname) \
if( dbname == tname::GetDBName() ) { \
m_parser.reset( \
new RecordParser<tname, BoostSaver<tname> >(
\
new BoostSaver<tname>(m_os) ) ); \
return; \
}
ALL_KNOWN_PARSER_TYPES
// if we make it here, we don't have a record parser
// for this dbname, so just dump it to stderr (not stdout,
// since the user might be sending normal output there)
m_parser.reset( new HexDumpParser(std::cerr) );
}
void ParseRecord(const DBData &data, const IConverter *ic)
{
if( m_current_db != data.GetDBName() ) {
StartDB(data.GetDBName());
m_current_db = data.GetDBName();
}
m_parser->ParseRecord(data, ic);
}
};
//
// BoostBuilder
//
/// This Builder class reads a boost serialization stream, and converts
/// them into DBData records. Can only produce records for record types
/// in ALL_KNOWN_BUILDER_TYPES.
///
class BXEXPORT BoostBuilder : public Barry::Builder
{
std::auto_ptr<Builder> m_builder;
std::ifstream *m_ifs;
std::istream &m_is; // references either an external object,
// or *m_ifs... this is the reference to
// use in the entire class... the constructo
r
// sets it up
public:
explicit BoostBuilder(const std::string &filename)
: m_ifs( new std::ifstream(filename.c_str()) )
, m_is(*m_ifs)
{
FinishDB();
}
explicit BoostBuilder(std::istream &is)
: m_ifs(0)
, m_is(is)
{
FinishDB();
}
~BoostBuilder()
{
delete m_ifs;
}
void FinishDB()
{
// done with current builder
m_builder.reset();
// read the next DBName
std::string dbName;
while( getline(m_is, dbName) ) {
#undef HANDLE_BUILDER
#define HANDLE_BUILDER(tname) \
if( dbName == tname::GetDBName() ) { \
m_builder.reset( \
new RecordBuilder<tname, BoostLoader
<tname> >( \
new BoostLoader<tname>(m_is)
) ); \
return; \
}
ALL_KNOWN_BUILDER_TYPES
}
}
bool BuildRecord(DBData &data, size_t &offset, const IConverter *ic)
{
if( !m_builder.get() )
return false;
bool ret = m_builder->BuildRecord(data, offset, ic);
if( !ret )
FinishDB();
return ret;
}
bool FetchRecord(DBData &data, const IConverter *ic)
{
if( !m_builder.get() )
return false;
bool ret = m_builder->FetchRecord(data, ic);
if( !ret )
FinishDB();
return ret;
}
bool EndOfFile() const
{
return m_builder.get() ? false : true;
}
};
} // namespace Barry
#endif #endif
 End of changes. 10 change blocks. 
1 lines changed or deleted 314 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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 85 skipping to change at line 85
// 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);
protected: protected:
bool SequencePacket(const Data &data); bool SequencePacket(const Data &data);
bool IsSequencePacketHidden() { return m_hideSequencePacket; } bool IsSequencePacketHidden() { return m_hideSequencePacket; }
public: public:
void SetResetOnClose(bool flag) { m_resetOnClose = flag; }
void HideSequencePacket(bool flag) { m_hideSequencePacket = flag; }
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
void ClearHalt();
}; };
// //
// 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
skipping to change at line 162 skipping to change at line 166
// an unopened socket defaults to socket 0, which you need // an unopened socket defaults to socket 0, which you need
// in order to set the blackberry mode // in order to set the blackberry mode
// The send function will overwrite the zeroSocketSequence byte // The send function will overwrite the zeroSocketSequence byte
// *inside* the packet, if the current m_socket is 0. // *inside* the packet, if the current m_socket is 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);
void ReceiveData(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 // sends the send packet down to the device, fragmenting if
// necessary, and returns the response in receive, defragmenting // necessary, and returns the response in receive, defragmenting
// if needed // if needed
// Blocks until response received or timed out in Usb::Device // Blocks until response received or timed out in Usb::Device
void Packet(Data &send, Data &receive, int timeout = -1); void Packet(Data &send, Data &receive, int timeout = -1);
void Packet(Barry::Packet &packet, int timeout = -1); void Packet(Barry::Packet &packet, int timeout = -1);
void Packet(Barry::JLPacket &packet, int timeout = -1); void Packet(Barry::JLPacket &packet, int timeout = -1);
void Packet(Barry::JVMPacket &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 // Use this function to send packet to JVM instead of Packet functio n
skipping to change at line 185 skipping to change at line 192
// Use this function to send data packet instead of Packet function // Use this function to send data packet instead of Packet function
// Indeed, Packet function is used to send command (and not data) // Indeed, Packet function is used to send command (and not data)
void PacketData(Data &send, Data &receive, int timeout = -1); void PacketData(Data &send, Data &receive, int timeout = -1);
// some handy wrappers for the Packet() interface // some handy wrappers for the Packet() interface
void NextRecord(Data &receive); void NextRecord(Data &receive);
// 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(SocketRoutingQueue::SocketDataHandler handler, void *context); void RegisterInterest(std::tr1::shared_ptr<SocketRoutingQueue::Socke tDataHandler> handler);
void UnregisterInterest(); void UnregisterInterest();
// This function is quickly written // This function is quickly written
// It's very durty :( (but it's usefull to test...) // It's very durty :( (but it's usefull to test...)
void HideSequencePacket(bool flag) { m_zero->HideSequencePacket(flag ); } void HideSequencePacket(bool flag) { m_zero->HideSequencePacket(flag ); }
}; };
} // namespace Barry } // namespace Barry
#endif #endif
 End of changes. 6 change blocks. 
4 lines changed or deleted 11 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2005-2011, 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


 usbwrap.h   usbwrap.h 
/// ///
/// \file usbwrap.h /// \file usbwrap.h
/// USB API wrapper /// USB API wrapper
/// ///
/* /*
Copyright (C) 2005-2009, Chris Frey Copyright (C) 2005-2011, Chris Frey
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,
// which causes trouble for other headers
#include <usb.h> #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
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.
skipping to change at line 114 skipping to change at line 120
~Device(); ~Device();
///////////////////////////// /////////////////////////////
// Data access // Data access
Usb::DeviceIDType GetID() const { return m_id; } Usb::DeviceIDType GetID() const { return m_id; }
Usb::DeviceHandleType GetHandle() const { return m_handle; } Usb::DeviceHandleType 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
int GetDefaultTimeout() const { return m_timeout; }
///////////////////////////// /////////////////////////////
// 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();
///////////////////////////// /////////////////////////////
// IO functions // IO functions
skipping to change at line 137 skipping to change at line 144
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);
///////////////////////////// /////////////////////////////
// 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();
}; };
 End of changes. 5 change blocks. 
1 lines changed or deleted 9 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-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2007-2011, 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


 vsmartptr.h   vsmartptr.h 
/// ///
/// \file vsmartptr /// \file vsmartptr
/// Variable 'free' smart pointer /// Variable 'free' smart pointer
/// ///
/* /*
Copyright (C) 2006-2009, Net Direct Inc. (http://www.netdirect.ca/) Copyright (C) 2006-2011, 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

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/