On Wed, 2012-08-29 at 15:13 -0600, Jeremy Whiting wrote:
> Ok, I've updated my syncpbap branch here:
> http://cgit.collabora.com/git/user/jwhiting/syncevolution.git but the
> completeCb and errorCb both never get called, so it just sits there.
> The transfer does happen, as the file is created and vcard data pumped
> in, but something is not right with the signalwatch.
Are you now running with a dbus daemon >= 1.5.0? I'm asking because I
don't see any changes in your branch to make the path prefix filtering
work with the older dbus that you were running.
> Is there a way
> I can check that the signalwatch is watching the right thing?
You can run with SYNCEVOLUTION_DEBUG=1 G_DBUS_DEBUG=message and
--daemon=no --print-items to see the D-Bus messages that SyncEvolution
sends and receives. Watch out for Add/RemoveMatch to see what kind of
filter it installs on the D-Bus daemon.
Additional filtering then happens in SignalFilter::matches() inside
SyncEvolution.
> Btw, feel free to offer any feedback on my use of StringPiece, I think
> what I have should work, but I've never used it before, so we'll see.
+ pcrecpp::StringPiece content(addr);
Still assumes that memory-mapped "addr" is 0-terminated (how else would
StringPiece know the length?). Use content(addr, sb.st_size).
+ typedef std::map<std::string, int> CounterMap;
+ CounterMap counterMap;
Any time you instantiate a std::string with data from "content", string
data has to be copied.
It would be better to let the Session object own the memory-mapped
content in a StringPiece, then use StringPiece everywhere else. It can
be used in standard containers.
+ string vcarddata;
Should be StringPiece.
+ pcrecpp::RE re("(BEGIN:VCARD.*END:VCARD)");
I doubt that this will match (doesn't match line breaks) and if it did,
it would match all vcards. Doesn't check that START/END occur at the
start of a line (will therefore fail when it is embedded as comment, for
example).
pcrecpp::RE re("(^BEGIN:VCARD.*?^END:VCARD)",
RE_Options().set_dotall(true));
+ while (re.Consume(&content, &vcarddata)) {
+ typedef std::map<std::string, std::string> VcardMap;
+ VcardMap vcard;
+ vcardParse(vcarddata, 0, vcarddata.length(), vcard);
The whole vcardParse can be removed for now. I left it enabled in "PBAP:
don't try to make up stable local IDs", but there's no need for it at
the moment.
+ VcardMap::const_iterator it = vcard.find("N");
+ if(it != vcard.end() && !it->second.empty()) {
+ const std::string &fn = it->second;
+
+ const std::pair<CounterMap::iterator, bool> &r =
+ counterMap.insert(CounterMap::value_type(fn, 0));
+ if(!r.second) {
+ r.first->second ++;
+ }
+
+ char suffix[8];
+ sprintf(suffix, "%07d", r.first->second);
+
+ std::string id = fn + std::string(suffix);
+ dst[id] = vcarddata;
That reverts "PBAP: don't try to make up stable local IDs".
This parsing code now exists in two variants: once for new API, once for
the old. You can use the StringPiece-based version for both by storing
the std::string in the Session object and then using a StringPiece which
references that in-memory data.
--
Best Regards, Patrick Ohly
The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.
_______________________________________________
SyncEvolution mailing list
[email protected]
http://lists.syncevolution.org/listinfo/syncevolution