3 /// Example code using the Barry library to add a memo
4 /// to a Blackberry device.
8 Copyright (C) 2009-2010, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #include <barry/barry.h>
29 using namespace Barry
;
32 void ReadLine(const char *prompt
, std::string
&data
)
34 cout
<< prompt
<< ": ";
38 void ReadInput(Barry::Memo
&memo
)
40 ReadLine("Title", memo
.Title
);
44 ReadLine("Body line (blank to end)", body
);
46 if( memo
.Body
.size() )
50 } while( body
.size() );
53 ReadLine("Categories", categories
);
54 memo
.Categories
.CategoryStr2List(categories
);
57 void Upload(const Barry::ProbeResult
&device
, const Barry::Memo
&memo
)
59 // connect to address book
60 Controller
con(device
);
61 Mode::Desktop
desktop(con
);
63 unsigned int id
= desktop
.GetDBID(Barry::Memo::GetDBName());
65 // find out what records are already there, and make new record ID
66 RecordStateTable table
;
67 desktop
.GetRecordStateTable(id
, table
);
68 uint32_t recordId
= table
.MakeNewRecordId();
71 desktop
.AddRecordByType(recordId
, memo
);
72 cout
<< "Added successfully." << endl
;
75 int main(int argc
, char *argv
[])
82 if( probe
.GetCount() == 0 ) {
83 cout
<< "No Blackberry found!" << endl
;
88 << probe
.Get(0).m_pin
.str() << endl
;
94 Upload(probe
.Get(0), memo
);
97 catch( std::exception
&e
) {
98 std::cerr
<< "Exception caught: " << e
.what() << endl
;