void agentLogout() { struct _agentInfo *info = &agentInfo; if (info->influence_device_name) { mapper_monitor_unlink(info->mon, info->influence_device_name, mdev_name(info->dev)); free(info->influence_device_name); } if (info->xagora_device_name) { mapper_monitor_unlink(info->mon, mdev_name(info->dev), info->xagora_device_name); free(info->xagora_device_name); } if (info->dev) mdev_free(info->dev); if (info->db) { mapper_db_remove_device_callback(info->db, dev_db_callback, info); mapper_db_remove_link_callback(info->db, link_db_callback, info); } if (info->mon) mapper_monitor_free(info->mon); if (info->admin) { mapper_admin_free(info->admin); } memset(info, 0, sizeof(struct _agentInfo)); }
void dev_db_callback(mapper_db_device record, mapper_db_action_t action, void *user) { // if we see /influence.1 or /XAgora.1, send /link message struct _agentInfo *info = (struct _agentInfo*)user; if (action == MDB_NEW) { if (strcmp(record->name, info->influence_device_name)==0) { mapper_monitor_link(info->mon, mdev_name(info->dev), record->name); mapper_monitor_link(info->mon, record->name, mdev_name(info->dev)); } else if (strcmp(record->name, info->xagora_device_name)==0) mapper_monitor_link(info->mon, mdev_name(info->dev), record->name); } else if (action == MDB_REMOVE) { if (strcmp(record->name, info->influence_device_name)==0) { mapper_monitor_unlink(info->mon, mdev_name(info->dev), record->name); info->linked_influence = 0; } } }
void recmonitor_stop() { if (!mon) return; if (mdev_ready(recdev)) { const char *devname = mdev_name(recdev); if (devname) { struct stringlist **node = &device_strings; while (*node) { mapper_db_device *dev = mapper_db_match_devices_by_name(db, (*node)->string); while (dev) { printf("Unlinking %s %s\n", (*dev)->name, devname); mapper_monitor_unlink(mon, (*dev)->name, devname); dev = mapper_db_device_next(dev); } node = &(*node)->next; } } } mapper_monitor_free(mon); }