00001 #include "uniconfroot-csharp.h"
00002 #include "uniconfroot.h"
00003 #include "uniwatch.h"
00004
00005 static uniconfroot_cb callback;
00006 static bool cc;
00007
00008 void uniconf_notify(const UniConf &uni, const UniConfKey &key)
00009 {
00010 if (cc)
00011 {
00012 callback(key.cstr());
00013 }
00014 }
00015
00016 uniconfroot_t uniconfroot_init()
00017 {
00018 UniConfRoot *root = new UniConfRoot();
00019
00020
00021 root->add_callback(root, UniConfKey::EMPTY, uniconf_notify, true);
00022 cc = false;
00023
00024 return (uniconfroot_t)root;
00025 }
00026
00027 uniconfroot_t uniconfroot_moniker(const char *mon, int refresh)
00028 {
00029 UniConfRoot *root = new UniConfRoot(mon, (bool)refresh);
00030
00031
00032 root->add_callback(root, UniConfKey::EMPTY, uniconf_notify, true);
00033
00034 cc = false;
00035
00036 return (uniconfroot_t)root;
00037 }
00038
00039 void uniconfroot_free(uniconfroot_t ur)
00040 {
00041 UniConfRoot *root = (UniConfRoot*)ur;
00042 root->del_callback(root, UniConfKey::EMPTY, true);
00043 delete root;
00044 }
00045
00046 void uniconfroot_setcb(uniconfroot_cb cb)
00047 {
00048 callback = cb;
00049 cc = true;
00050 }
00051