On Fr, 2011-08-05 at 11:03 +0300, Dumez, Christophe wrote:
> + if (!e_book_client_get_view_sync(m_addressbook.get(), sexp,
> &view, NULL, gerror)) {
> + gerror.throwError( "getting the view" );
> + }
> + EBookClientViewCXX viewWrapper = EBookClientViewCXX::steal(view);
Would it make sense to extend SE_GOBJECT_TYPE = EBookClientViewCXX such
that it supports the same initialization as GListCXX by simply passing
it to GNOME functions?
Like this:
EBookClientViewCXX view;
if (!e_book_client_get_view_sync(m_addressbook.get(), sexp, view, NULL,
gerror)) {
gerror.throwError( "getting the view" );
}
Implementing it won't be as easy as for GListCXX, because
EBookClientViewCXX is a boost::shared_pointer. Just wondering... ;-)
+ EvolutionContactAsyncList async_list(view);
+
+ if (!async_list.m_error.isNull()) {
+ async_list.m_error.throwError("watching view");
+ }
+
+ GSList *nextItem = async_list.m_contacts;
+ GListCXX<EContact, GSList, GObjectDestructor<EContact> > listptr(nextItem);
Indention problem, but my main question is: how is ownership of the list
elements handled here? Isn't there a double unref, once inside
async_list.m_contacts and once in listptr?
>From GLibSupport.h:
+template<class T> void GObjectDestructor(T *obj);
Does that really work? Doesn't the template definition have to be
visible here for it to be used?
+/**
+ * Wraps a C char array and takes care of freeing the memory.
+ */
+class PlainCStr : public boost::shared_ptr<char>
+{
+ public:
+ PlainCStr() {}
+ PlainCStr(char *str) : boost::shared_ptr<char>(str, free) {}
+ PlainCStr(const PlainCStr &other) :
boost::shared_ptr<char>(other) {}
+ operator const char *() const { return &**this; }
+ const char *c_str() const { return &**this; }
+};
Note that free() != g_free(). This PlainCStr is used for strings
allocated by GNOME, isn't it? Then we need a second PlainGStr which uses
g_free().
Other than that the patch looks good. Does it pass the
Client::Source::eds_contact tests? To run that, configure with
--enable-integration-tests, see the HACKING document.
--
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