static GC _gadgetParentBottomShadowGC(XmLabelGadget _label) { XGCValues gcValues; XtGCMask mask; XFontStruct *fs; XmManagerWidget parent = (XmManagerWidget)XtParent(_label); mask = GCForeground | GCBackground; gcValues.foreground = MANAGER(parent).bottom_shadow_color; gcValues.background = MANAGER(parent).foreground; if ((MANAGER(parent).bottom_shadow_pixmap != None) && (MANAGER(parent).bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP)) { mask |= GCFillStyle | GCTile; gcValues.fill_style = FillTiled; gcValues.tile = MANAGER(parent).bottom_shadow_pixmap; } _XmFontListGetDefaultFont(LABEL(_label).font, &fs); if (fs != 0) { mask |= GCFont; gcValues.font = fs->fid; } return XtGetGC ((Widget)parent, mask, &gcValues); }
int chat_kick( int unum, char *msg ) { char *twit = nextword(&msg); int rnum = users[unum].room; int recunum; if (!OPERATOR(unum) && !MANAGER(unum)) { send_to_unum(unum, "*** You're not operator\n", -1); return 0; } if ((recunum = chatid_to_indx(twit)) == -1) { /* no such user */ sprintf(genbuf, "*** No such chatid '%s'\n", twit); send_to_unum(unum, genbuf, -1); return 0; } if (rnum != users[recunum].room) { sprintf(genbuf, "*** '%s' is not in this room\n", users[recunum].chatid); send_to_unum(unum, genbuf, -1); return 0; } exit_room(recunum, EXIT_KICK, msg); if (rnum == 0) logout_user(recunum); else enter_room(recunum, mainroom, (char *)NULL); return 0; }
chat_map_chatids(int unum) { int i, c, myroom, rnum; myroom = users[unum].room; send_to_unum(unum, "*** Chatid Userid Chatid Userid Chatid Userid\n", -1); send_to_unum(unum, "*** ------ ------ ------ ------ ------ ------\n", -1); strcpy(genbuf, "*** "); for (i=0, c=0; i<bbs_max_users; i++) { rnum = users[i].room; if (users[i].sockfd != -1 && rnum != -1) { if (myroom != rnum) { if (RESTRICTED(unum)) continue; if ((rooms[rnum].flags & ROOM_SECRET) && !MANAGER(unum)) continue; } sprintf(genbuf+(c*24)+4, "%-8s %-12s \n", users[i].chatid, users[i].userid); if (++c == 3) { send_to_unum(unum, genbuf, -1); c = 0; } } } if (c > 0) send_to_unum(unum, genbuf, -1); return 0; }
static void on_hostname_proxy_ready (GObject *source, GAsyncResult *result, gpointer user_data) { Manager *self = MANAGER (user_data); GError *error = NULL; self->hostname1_proxy = g_dbus_proxy_new_for_bus_finish (result, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { /* nothing */ } else if (self->hostname1_proxy == NULL) { g_warning ("Unable to create hostname1 proxy: %s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); } else { update_hostname1 (self); g_signal_connect (self->hostname1_proxy, "g-properties-changed", G_CALLBACK (on_hostname1_properties_changed), self); } g_object_unref (self); }
int chat_do_user_list( int unum, char *msg, int whichroom ) { int start, stop, curr = 0; int i, rnum, myroom = users[unum].room; while (*msg && isspace(*msg)) msg++; start = atoi(msg); while (*msg && isdigit(*msg)) msg++; while (*msg && !isdigit(*msg)) msg++; stop = atoi(msg); send_to_unum(unum, "***\n", -1); send_to_unum(unum, "*** Nick Userid Room\n", -1); send_to_unum(unum, "*** ---- ------ ----\n", -1); for (i=0; i<bbs_max_users; i++) { rnum = users[i].room; if (users[i].sockfd != -1 && rnum != -1) { if (whichroom != -1 && whichroom != rnum) continue; if (myroom != rnum) { if (RESTRICTED(unum)) continue; if ((rooms[rnum].flags & ROOM_SECRET) && !MANAGER(unum)) continue; } curr++; if (curr < start) continue; else if (stop && (curr > stop)) break; sprintf(genbuf, "*** %-9s %-15s %s", users[i].chatid, users[i].userid, rooms[rnum].name); if (OPERATOR(i)) strcat(genbuf, " (Op)"); strcat(genbuf, "\n"); send_to_unum(unum, genbuf, -1); } } return 0; }
/*ARGSUSED*/ int chat_list_rooms( int unum, char *msg ) { int i, occupants; if (RESTRICTED(unum)) { send_to_unum(unum, "*** You do not have permission to list rooms\n", -1); return 0; } send_to_unum(unum, "***\n", -1); send_to_unum(unum, "*** Room Users\n", -1); send_to_unum(unum, "*** ---- -----\n", -1); for (i=0; i<bbs_max_users; i++) { occupants = rooms[i].occupants; if (occupants > 0) { if (!MANAGER(unum)) if ((rooms[i].flags & ROOM_SECRET) && (users[unum].room != i)) continue; sprintf(genbuf, "*** %-15s %3d", rooms[i].name, occupants); if (rooms[i].flags & ROOM_LOCKED) strcat(genbuf, " (LOCKED)"); if (rooms[i].flags & ROOM_SECRET) strcat(genbuf, " (SECRET)"); strcat(genbuf, "\n"); send_to_unum(unum, genbuf, -1); } } return 0; }
static void manager_finalize (GObject *object) { Manager *self = MANAGER (object); G_OBJECT_CLASS (manager_parent_class)->finalize (object); }
static void manager_constructed (GObject *object) { Manager *manager = MANAGER (object); GError *error = NULL; gs_unref_object GFile *etc_os_release = g_file_new_for_path ("/etc/os-release"); gs_free gchar *hostname; manager->etc_os_release_monitor = g_file_monitor (etc_os_release, G_FILE_MONITOR_NONE, NULL, &error); if (!manager->etc_os_release_monitor) { g_warning ("Error monitoring /etc/os-release: %s", error->message); g_error_free (error); } else { g_signal_connect (manager->etc_os_release_monitor, "changed", G_CALLBACK (on_etc_os_release_changed), manager); reread_os_release (manager); } hostname = g_malloc0 (HOST_NAME_MAX + 1); gethostname (hostname, HOST_NAME_MAX); hostname[HOST_NAME_MAX] = '\0'; cockpit_manager_set_hostname (COCKPIT_MANAGER (manager), hostname); g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES, NULL, /* GDBusInterfaceInfo* */ "org.freedesktop.hostname1", "/org/freedesktop/hostname1", "org.freedesktop.hostname1", manager->cancellable, on_hostname_proxy_ready, g_object_ref (manager)); update_dmi (manager); error = NULL; gs_unref_object GFile *f = g_file_new_for_path ("/run/systemd/shutdown/scheduled"); manager->systemd_shutdown_schedule_monitor = g_file_monitor_file (f, 0, NULL, &error); if (error) { g_warning ("Can't watch: %s", error->message); g_error_free (error); } else { g_signal_connect (manager->systemd_shutdown_schedule_monitor, "changed", G_CALLBACK (on_systemd_shutdown_scheduled_changed), manager); } if (G_OBJECT_CLASS (manager_parent_class)->constructed != NULL) G_OBJECT_CLASS (manager_parent_class)->constructed (object); }
static void manager_dispose (GObject *object) { Manager *self = MANAGER (object); g_cancellable_cancel (self->cancellable); G_OBJECT_CLASS (manager_parent_class)->dispose (object); }
static void on_hostname1_properties_changed (GDBusProxy *proxy, GVariant *changed_properties, const gchar * const *invalidated_properties, gpointer user_data) { Manager *manager = MANAGER (user_data); update_hostname1 (manager); }
struct MANAGER(Curve) *Cmiss_context_get_default_curve_manager( Cmiss_context_id context) { MANAGER(Curve) *curve_manager = NULL; if (context) { if (!context->curve_manager) { context->curve_manager = CREATE(MANAGER(Curve))(); } curve_manager = context->curve_manager; } else { display_message(ERROR_MESSAGE, "Cmiss_context_get_default_curve_manager. " "Missing context"); } return curve_manager; }
/* runs in thread dedicated to handling the method call so may block */ static gboolean handle_set_hostname (CockpitManager *_manager, GDBusMethodInvocation *invocation, const gchar *arg_pretty_hostname, const gchar *arg_hostname, GVariant *arg_options) { Manager *manager = MANAGER (_manager); GError *error; if (!auth_check_sender_role (invocation, COCKPIT_ROLE_ADMIN)) return TRUE; /* TODO: validate that passed @arg_hostname is not malformed (e.g. only ASCII etc.) */ if (strlen (arg_pretty_hostname) > 0) { error = NULL; if (!g_dbus_proxy_call_sync (manager->hostname1_proxy, "SetPrettyHostname", g_variant_new ("(sb)", arg_pretty_hostname, FALSE), G_DBUS_CALL_FLAGS_NONE, -1, /* timeout_msec */ NULL, /* GCancellable* */ &error)) { g_dbus_error_strip_remote_error (error); g_dbus_method_invocation_take_error (invocation, error); goto out; } } if (strlen (arg_hostname) > 0) { error = NULL; if (!g_dbus_proxy_call_sync (manager->hostname1_proxy, "SetHostname", g_variant_new ("(sb)", arg_hostname, FALSE), G_DBUS_CALL_FLAGS_NONE, -1, /* timeout_msec */ NULL, /* GCancellable* */ &error)) { g_dbus_error_strip_remote_error (error); g_dbus_method_invocation_take_error (invocation, error); goto out; } } cockpit_manager_complete_set_hostname (COCKPIT_MANAGER (manager), invocation); out: return TRUE; /* Means we handled the invocation */ }
int print_user_counts(int unum) { int i, c, userc = 0, suserc = 0, roomc = 0; for (i=0; i<bbs_max_users; i++) { c = rooms[i].occupants; if (i > 0 && c > 0) { if (!SECRET(i) || MANAGER(unum)) roomc++; } c = users[i].room; if (users[i].sockfd != -1 && c != -1) { if (SECRET(c) && !MANAGER(unum)) suserc++; else userc++; } } sprintf(genbuf, "*** %d other user(s) present", userc); if (suserc) sprintf(genbuf+strlen(genbuf), " (+ %d in secret rooms)", suserc); strcat(genbuf, "\n"); send_to_unum(unum, genbuf, -1); sprintf(genbuf, "*** %d other visible room(s) in use\n", roomc); send_to_unum(unum, genbuf, -1); return 0; }
int enter_room( int unum, char *room, char *msg ) { int rnum = roomid_to_indx(room); int op = 0; register int i; if (rnum == -1) { /* new room */ for (i=1; i<bbs_max_users; i++) { if (rooms[i].occupants == 0) { rnum = i; if (rooms[rnum].invites == NULL) { rooms[rnum].invites = (char *)malloc(bbs_max_users); if (rooms[rnum].invites == NULL) { send_to_unum(unum, "*** Not enough memory\n", -1); return 0; } } memset(rooms[rnum].invites, 0, bbs_max_users); strncpy(rooms[rnum].name, room, NAMELEN); rooms[rnum].name[NAMELEN] = '\0'; rooms[rnum].flags = 0; op++; break; } } if (rnum == -1) { send_to_unum(unum, "*** No more rooms available\n", -1); return 0; } } if (!MANAGER(unum)) if (LOCKED(rnum) && rooms[rnum].invites[unum] == 0) { send_to_unum(unum, "*** Cannot enter locked room without a key\n", -1); return 0; } exit_room(unum, EXIT_LOGOUT, msg); users[unum].room = rnum; if (op) users[unum].flags |= FLG_CHATOP; rooms[rnum].occupants++; rooms[rnum].invites[unum] = 0; sprintf(genbuf, "*** %s has entered room '%s'\n", users[unum].chatid, rooms[rnum].name); send_to_room(rnum, genbuf, unum); return 0; }
int chat_broadcast( int unum, char *msg ) { if (!MANAGER(unum)) { send_to_unum(unum, "*** You can't do that\n", -1); return 0; } if (*msg == '\0') { send_to_unum(unum, "*** No message given\n", -1); return 0; } sprintf(genbuf, "*** Broadcast message from %s:\n", users[unum].chatid); send_to_room(ROOM_ALL, genbuf, -1); strcpy(genbuf, "*** "); strncat(genbuf, msg, CHATLINE_TEXT_MAX); send_to_room(ROOM_ALL, genbuf, -1); return 0; }
chat_list_by_room( int unum, char *msg ) { int whichroom; char *roomstr = nextword(&msg); if (*roomstr == '\0') whichroom = users[unum].room; else { if ((whichroom = roomid_to_indx(roomstr)) == -1) { sprintf(genbuf, "*** No such room '%s'\n", roomstr); send_to_unum(unum, genbuf, -1); return 0; } if ((rooms[whichroom].flags & ROOM_SECRET) && !MANAGER(unum)) { send_to_unum(unum, "*** Cannot list users in secret rooms\n", -1); return 0; } } return (chat_do_user_list(unum, msg, whichroom)); }
static void manager_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { Manager *manager = MANAGER (object); switch (prop_id) { case PROP_DAEMON: g_value_set_object (value, manager_get_daemon (manager)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void manager_finalize (GObject *object) { Manager *manager = MANAGER (object); if (manager->hostname1_proxy != NULL) { g_signal_handlers_disconnect_by_func (manager->hostname1_proxy, G_CALLBACK (on_hostname1_properties_changed), manager); g_object_unref (manager->hostname1_proxy); } if (manager->systemd_shutdown_schedule_monitor) g_object_unref (manager->systemd_shutdown_schedule_monitor); g_clear_object (&manager->etc_os_release_monitor); G_OBJECT_CLASS (manager_parent_class)->finalize (object); }
static void manager_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { Manager *manager = MANAGER (object); switch (prop_id) { case PROP_DAEMON: g_assert (manager->daemon == NULL); /* we don't take a reference to the daemon */ manager->daemon = g_value_get_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
int chat_ignore( int unum, char *msg ) { if (*msg == '\0') { if (users[unum].ignorelist == NULL) send_to_unum(unum, "*** You're not ignoring anyone\n", -1); else { apply_namelist(users[unum].ignorelist, _show_ignores, &unum); } } else { int inum; char *ignoree = nextword(&msg); inum = userid_to_indx(ignoree); if (inum == -1) { sprintf(genbuf, "*** User '%s' is not in chat\n", ignoree); send_to_unum(unum, genbuf, -1); } #if NO_IGNORE_CHATOPS else if (MANAGER(inum)) { sprintf(genbuf, "*** You can't ignore '%s'\n", ignoree); send_to_unum(unum, genbuf, -1); } #endif else { int ignoring = is_in_namelist(users[unum].ignorelist, ignoree); if (ignoring) { sprintf(genbuf, "*** Already ignoring user '%s'\n", ignoree); } else { add_namelist(&users[unum].ignorelist, ignoree, NULL); sprintf(genbuf, "*** Ignoring user '%s'\n", ignoree); _set_ignores(ignoree, unum, 1); } send_to_unum(unum, genbuf, -1); } } return 0; }
* the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include <graphics/tessellation.hpp> #include <wx/wx.h> #include <map> #ifndef TESSELATION_DIALOG_HPP #define TESSELATION_DIALOG_HPP class TessellationItem : public wxPanel { public: TessellationItem(wxWindow* parent, MANAGER(Cmiss_tessellation) *tessellation_manager_in, Cmiss_tessellation *tessellation_in); void update_global(); private: Cmiss_tessellation *tessellation; int labelChanged, refinementChanged, divisionsChanged; MANAGER(Cmiss_tessellation) *tessellation_manager; void do_layout(); void set_callback(); void update_divisions_string_for_dialog(); void update_refinement_string_for_dialog(); void OnTessellationTextEntered(wxCommandEvent& event); void OnTessellationApplyPressed(wxCommandEvent& event);
int Cmiss_context_destroy(struct Context **context_address) { int return_code = 0; struct Context *context = NULL; if (context_address && NULL != (context = *context_address)) { context->access_count--; if (0 == context->access_count) { if (context->id) DEALLOCATE(context->id); //-- if (context->UI_module) //-- { //-- User_interface_module_destroy(&context->UI_module); //-- } if (context->graphics_module) Cmiss_graphics_module_destroy(&context->graphics_module); if (context->root_region) { /* need the following due to circular references where field owned by region references region itself; * when following removed also remove #include "region/cmiss_region_private.h". Also rendition * has a computed_field manager callback so it must be deleted before detaching fields hierarchical */ Cmiss_region_detach_fields_hierarchical(context->root_region); DEACCESS(Cmiss_region)(&context->root_region); } if (context->scene_viewer_package) { Cmiss_scene_viewer_package_destroy(&context->scene_viewer_package); } if (context->any_object_selection) { DESTROY(Any_object_selection)(&context->any_object_selection); } if (context->element_point_ranges_selection) { DESTROY(Element_point_ranges_selection)(&context->element_point_ranges_selection); } if (context->curve_manager) { DESTROY(MANAGER(Curve))(&context->curve_manager); } if (context->io_stream_package) { DESTROY(IO_stream_package)(&context->io_stream_package); } //-- if (context->event_dispatcher) //-- { //-- DESTROY(Event_dispatcher)(&context->event_dispatcher); //-- } DEALLOCATE(*context_address); } *context_address = NULL; return_code = 1; } else { display_message(ERROR_MESSAGE, "Cmiss_context_destroy. Missing context address"); return_code = 0; } /* Write out any memory blocks still ALLOCATED when MEMORY_CHECKING is on. When MEMORY_CHECKING is off this function does nothing */ list_memory(/*count_number*/0, /*show_pointers*/0, /*increment_counter*/0, /*show_structures*/1); return return_code; }