void run_gui(void) { gtk_signal_connect(GTK_OBJECT(main_window), "delete_event", GTK_SIGNAL_FUNC(do_quit), NULL); gtk_signal_connect(GTK_OBJECT(quit_button), "pressed", GTK_SIGNAL_FUNC(do_quit), NULL); gtk_signal_connect(GTK_OBJECT(port_entry), "changed", GTK_SIGNAL_FUNC(do_new_port), NULL); gtk_signal_connect(GTK_OBJECT(GTK_COMBO(baud_combo)->entry), "changed", GTK_SIGNAL_FUNC(do_new_baud), NULL); gtk_signal_connect(GTK_OBJECT(firmware_entry), "changed", GTK_SIGNAL_FUNC(do_new_file), NULL); gtk_signal_connect(GTK_OBJECT(crystal_entry), "changed", GTK_SIGNAL_FUNC(do_new_crystal), NULL); gtk_signal_connect(GTK_OBJECT(program_button), "pressed", GTK_SIGNAL_FUNC(do_program), NULL); gtk_signal_connect(GTK_OBJECT(reboot_button), "pressed", GTK_SIGNAL_FUNC(do_reboot), NULL); gtk_signal_connect(GTK_OBJECT(bootloader_button), "pressed", GTK_SIGNAL_FUNC(do_bootloader), NULL); gtk_timeout_add(100, do_timer, NULL); gdk_input_add(term_fd, GDK_INPUT_READ, do_term_input, NULL); gdk_input_add(serial_port_fd(), GDK_INPUT_READ, do_port_input, NULL); gtk_main(); }
// -------------------------------------------------------------------------- // StartProduction(): see wxSoundStream // -------------------------------------------------------------------------- bool wxSoundStreamESD::StartProduction(int evt) { #ifndef HAVE_ESD_H m_snderror = wxSOUND_INVDEV; return false; #else wxSoundFormatPcm *pcm; int flag = 0; if (!m_esd_ok) { m_snderror = wxSOUND_INVDEV; return false; } if (!m_esd_stop) StopProduction(); pcm = (wxSoundFormatPcm *)m_sndformat; flag |= (pcm->GetBPS() == 16) ? ESD_BITS16 : ESD_BITS8; flag |= (pcm->GetChannels() == 2) ? ESD_STEREO : ESD_MONO; if ((evt & wxSOUND_OUTPUT) != 0) { flag |= ESD_PLAY | ESD_STREAM; m_fd_output = esd_play_stream(flag, pcm->GetSampleRate(), NULL, MY_ESD_NAME); } if ((evt & wxSOUND_INPUT) != 0) { flag |= ESD_RECORD | ESD_STREAM; m_fd_input = esd_record_stream(flag, pcm->GetSampleRate(), NULL, MY_ESD_NAME); } #ifdef __WXGTK__ if ((evt & wxSOUND_OUTPUT) != 0) { m_tag_output = gdk_input_add(m_fd_output, GDK_INPUT_WRITE, _wxSound_OSS_CBack, (gpointer)this); } if ((evt & wxSOUND_INPUT) != 0) { m_tag_input = gdk_input_add(m_fd_input, GDK_INPUT_READ, _wxSound_OSS_CBack, (gpointer)this); } #endif m_esd_stop = false; m_q_filled = false; return true; #endif // defined HAVE_ESD_H }
int main(int argc, char *argv[]) { int i; /* copy our argument list */ const char **argvn = (const char **) malloc(sizeof(char*)*(argc+3)); if(argvn==0) { fprintf(stderr,"malloc failed\n"); exit(1); } argvn[0] = PLAY_PROG; argvn[1] = "-q"; argvn[2] = "-g"; for(i=1;i<argc;i++) argvn[i+2] = argv[i]; argvn[argc+2] = 0; create_child(argvn); gtk_init (&argc, &argv); gtk_xlav = create_form_xlav(); // old: gtk_signal_connect (GTK_OBJECT (gtk_xlav->xlav), "destroy", // old: GTK_SIGNAL_FUNC(gtk_main_quit), NULL); g_signal_connect_swapped(G_OBJECT (gtk_xlav->xlav), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show(gtk_xlav->xlav); /* show the main window */ gdk_input_add(inp_pipe,GDK_INPUT_READ,(GdkInputFunction)get_input,(gpointer)0); gtk_main(); return 0; }
void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket *socket, GSocketEvent event) { gint *m_id = (gint *)(socket->m_gui_dependent); int c; if (socket->m_fd == -1) return; switch (event) { case GSOCK_LOST: /* fall-through */ case GSOCK_INPUT: c = 0; break; case GSOCK_OUTPUT: c = 1; break; case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break; default: return; } if (m_id[c] != -1) gdk_input_remove(m_id[c]); m_id[c] = gdk_input_add(socket->m_fd, (c ? GDK_INPUT_WRITE : GDK_INPUT_READ), _GSocket_GDK_Input, (gpointer)socket); }
uxsel_id *uxsel_input_add(int fd, int rwx) { uxsel_id *id = snew(uxsel_id); #if GTK_CHECK_VERSION(2, 0, 0) int flags = 0; if (rwx & 1) flags |= G_IO_IN; if (rwx & 2) flags |= G_IO_OUT; if (rwx & 4) flags |= G_IO_PRI; id->chan = g_io_channel_unix_new(fd); g_io_channel_set_encoding(id->chan, NULL, NULL); id->watch_id = g_io_add_watch_full( id->chan, GDK_PRIORITY_REDRAW + 1, flags, fd_input_func, NULL, NULL); #else int flags = 0; if (rwx & 1) flags |= GDK_INPUT_READ; if (rwx & 2) flags |= GDK_INPUT_WRITE; if (rwx & 4) flags |= GDK_INPUT_EXCEPTION; assert(flags); id->id = gdk_input_add(fd, flags, fd_input_func, NULL); #endif return id; }
/* Our main function of the ptest thread */ static void *start_tgtk_thread(void *args) { /* create our pipes, if we can */ if (pipe(tgtk_pipe)) { /* pipe failed, might as well kill gtk thread */ kill_tgtk_callback(NULL); return NULL; } if (pipe(tgtk_pipe2)) { /* pipe failed, might as well kill gtk thread */ kill_tgtk_callback(NULL); return NULL; } /* Register our new fds with new_open(). BTW, new_open implies * that it is going to do an open(), it won't. It just adjusts * our "max_fd" var, so that it will scan our fd */ new_open(tgtk_pipe[0]); new_open(tgtk_pipe[1]); new_open(tgtk_pipe2[0]); new_open(tgtk_pipe2[1]); /* create a callback in gtk for input on this pipe 1[0] */ gdk_input_add(tgtk_pipe[0], GDK_INPUT_READ, tgtk_get_message_in_gtk_thread, NULL); /* Set flag telling us that gtk and our pipes are up and running */ _tgtk_okay = 1; /* Send message to any listening select() loop that everything is up */ if (_someone_listening) { send_message_that_gtk_is_up(); _sent_gtk_okay_message = 1; } /* Run the gtk message pump */ gtk_main(); return &ecode; }
static void connect(GtkWidget *widget, gpointer data) { counter = counter_create(dev, measure, range); if (counter != NULL) fd_tag = gdk_input_add(counter->port->fd, GDK_INPUT_READ, counter_callback, NULL); }
int main (int argc, char *argv[]) { GtkWidget *window; /* Init GTK stuffs */ gtk_set_locale(); gtk_init(&argc, &argv); /* Get command arguments */ if ( argc > 1 ) usage(); /* Add pixmap search path */ { char *home = get_home(); char path[strlen(home)+10]; snprintf(path, sizeof(path), "%s/icons", home); add_pixmap_directory(path); } add_pixmap_directory ("."); /* Start Report Config gui */ window = report_config_gui(NULL); gtk_signal_connect_object(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), (gpointer) NULL); /* Setup control command handling */ command_id = gdk_input_add(fileno(stdin), GDK_INPUT_READ, (GdkInputFunction) command_handler, window); gtk_main(); return 0; }
bool wxSoundStreamOSS::StartProduction(int evt) { wxSoundFormatBase *old_frmt; if (!m_oss_stop) StopProduction(); old_frmt = m_sndformat->Clone(); if (!old_frmt) { m_snderror = wxSOUND_MEMERROR; return false; } if (evt == wxSOUND_OUTPUT) m_fd = open(m_devname.mb_str(), O_WRONLY); else if (evt == wxSOUND_INPUT) m_fd = open(m_devname.mb_str(), O_RDONLY); if (m_fd == -1) { m_snderror = wxSOUND_INVDEV; return false; } SetSoundFormat(*old_frmt); delete old_frmt; int trig; if (evt == wxSOUND_OUTPUT) { #ifdef __WXGTK__ m_tag = gdk_input_add(m_fd, GDK_INPUT_WRITE, _wxSound_OSS_CBack, (gpointer)this); #endif trig = PCM_ENABLE_OUTPUT; } else { #ifdef __WXGTK__ m_tag = gdk_input_add(m_fd, GDK_INPUT_READ, _wxSound_OSS_CBack, (gpointer)this); #endif trig = PCM_ENABLE_INPUT; } ioctl(m_fd, SNDCTL_DSP_SETTRIGGER, &trig); m_oss_stop = false; m_q_filled = false; return true; }
int wxGUIAppTraits::AddProcessCallback(wxEndProcessData *proc_data, int fd) { int tag = gdk_input_add(fd, GDK_INPUT_READ, GTK_EndProcessDetector, (gpointer)proc_data); return tag; }
virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d) { return gdk_input_add ( fd, d == OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ, wxSocket_GDK_Input, handler ); }
void IliadToolbar::setChannel(erServerChannel_t channel) { erIpcChannel = channel; int fd = erIpcGetServerFd(channel); gdk_input_add (fd, GDK_INPUT_READ, (GdkInputFunction) ipcCbk, (gpointer) this); }
static void viewer_fam_open(viewer_t *viewer) { viewer->fc_tag = -1; viewer->fc_req_ok = 0; if ( FAMOpen2(&(viewer->fc), NAME) ) { fprintf(stderr, NAME ": WARNING: Failed to open FAM connection. No file updates will be detected.\n"); } else { viewer->fc_tag = gdk_input_add(FAMCONNECTION_GETFD(&(viewer->fc)), GDK_INPUT_READ, (GdkInputFunction) viewer_fam_input, (gpointer) viewer); } }
void carmen_graphics_update_ipc_callbacks(GdkInputFunction callback_Func) { fd_set *open_fds; int max_connection; int index; int callback_index; carmen_graphics_callback *callback; carmen_graphics_callback new_callback; static carmen_list_t *existing_callbacks = NULL; static int num_callbacks = 0; if (existing_callbacks == NULL) existing_callbacks = carmen_list_create(sizeof(carmen_graphics_callback), 10); for (index = 0; index < num_callbacks; index++) { callback = carmen_list_get(existing_callbacks, index); callback->ok = 0; } open_fds = x_ipcGetConnections(); max_connection = x_ipcGetMaxConnection(); for (index = 0; index <= max_connection; index++) { if (FD_ISSET(index, open_fds)) { for (callback_index = 0; callback_index < num_callbacks; callback_index++) { callback = carmen_list_get(existing_callbacks, callback_index); if (index == callback->fd) { callback->ok = 1; break; } } if (callback_index == existing_callbacks->length) { new_callback.fd = index; new_callback.ok = 1; new_callback.callback_id = gdk_input_add(index, GDK_INPUT_READ, callback_Func, NULL); carmen_list_add(existing_callbacks, &new_callback); } } /* End of if (FD_ISSET(index, open_fds)) */ } /* End of for (index = 0; index <= max_connection; index++) */ for (index = 0; index < num_callbacks; index++) { callback = carmen_list_get(existing_callbacks, index); if (callback->ok == 0) { gdk_input_remove(callback->callback_id); carmen_list_delete(existing_callbacks, index); index--; } } }
int main(int argc, char *argv[]) { if (argc < 5) { g_critical("not enough arguments supplied"); return 1; } gtk_init(&argc, &argv); //char *exe_path = argv[0]; char *host_url = argv[1]; //char *lib_name = argv[2]; char *plug_name = argv[3]; char *identifier = argv[4]; _osc_path = lo_url_get_path(host_url); _osc_host_addr = lo_address_new_from_url(host_url); _osc_server = lo_server_new(NULL, osc_error); lo_server_add_method(_osc_server, tmpstr("/%s/control", _osc_path), "if", osc_control_handler, NULL); lo_server_add_method(_osc_server, tmpstr("/%s/sample-rate", _osc_path), "i", osc_samplerate_handler, NULL); lo_server_add_method(_osc_server, tmpstr("/%s/program", _osc_path), "ii", osc_program_handler, NULL); lo_server_add_method(_osc_server, tmpstr("/%s/show", _osc_path), NULL, osc_show_handler, NULL); lo_server_add_method(_osc_server, tmpstr("/%s/hide", _osc_path), NULL, osc_hide_handler, NULL); lo_server_add_method(_osc_server, tmpstr("/%s/quit", _osc_path), NULL, osc_quit_handler, NULL); lo_server_add_method(_osc_server, NULL, NULL, osc_fallback_handler, NULL); host_request_update(); gdk_input_add(lo_server_get_socket_fd(_osc_server), GDK_INPUT_READ, (GdkInputFunction)lo_server_recv_noblock, _osc_server); _window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); gtk_window_set_title(_window, tmpstr("%s - %s", plug_name, identifier)); gtk_signal_connect(GTK_OBJECT(_window), "delete-event", on_window_deleted, NULL); size_t i; for (i=0; i<kAmsynthParameterCount; i++) { gdouble value = 0, lower = 0, upper = 0, step_increment = 0; get_parameter_properties(i, &lower, &upper, &value, &step_increment); _adjustments[i] = (GtkAdjustment *)gtk_adjustment_new(value, lower, upper, step_increment, 0, 0); g_signal_connect(_adjustments[i], "value-changed", (GCallback)&on_adjustment_value_changed, (gpointer)i); } GtkWidget *editor = editor_pane_new(new SynthesizerStub, _adjustments, TRUE); gtk_container_add(GTK_CONTAINER(_window), editor); gtk_widget_show_all(GTK_WIDGET(editor)); gtk_main(); return 0; }
static int connect(struct conduit *conduit) { struct data *data; data = conduit->cdata; if(inuse != NULL) return(-1); if((data->fd = dc_connect(NULL)) < 0) return(-1); data->gdkread = gdk_input_add(data->fd, GDK_INPUT_READ, (void (*)(gpointer, int, GdkInputCondition))dcfdcb, conduit); updatewrite(conduit); inuse = conduit; return(0); }
/** c2_imap_reconnect * * @imap: A locked imap object * * This function attempts to reconnect and restore * proper state of an imap object. * * Return Value: * 0 on success, -1 otherwise **/ static gint c2_imap_reconnect(C2IMAP *imap) { C2NetObjectByte *byte; c2_net_object_disconnect(C2_NET_OBJECT(imap)); c2_net_object_destroy_byte(C2_NET_OBJECT(imap)); gdk_input_remove(imap->input_tag); imap->input_tag = -1; if(!(byte = c2_net_object_run(C2_NET_OBJECT(imap)))) { imap->state = C2IMAPDisconnected; gtk_signal_emit(GTK_OBJECT(imap), signals[NET_ERROR]); c2_imap_set_error(imap, _("Error connecting to IMAP server.")); return -1; } imap->input_tag = gdk_input_add(byte->sock, GDK_INPUT_READ, (GdkInputFunction)c2_imap_on_net_traffic, imap); imap->input_tag = gdk_input_add(byte->sock, GDK_INPUT_READ, (GdkInputFunction)c2_imap_on_net_traffic, imap); imap->login(imap); if(imap->state == C2IMAPSelected) if(c2_imap_select_mailbox(imap, imap->selected_mailbox) < 0) { c2_net_object_disconnect(C2_NET_OBJECT(imap)); gtk_signal_emit(GTK_OBJECT(imap), signals[LOGOUT]); return -1; } return 0; }
static VALUE rg_m_add(VALUE self, VALUE filedescriptor, VALUE gdk_input_condition) { VALUE id; VALUE func; func = rb_block_proc(); id = INT2FIX(gdk_input_add(NUM2INT(rb_funcall(filedescriptor, rb_intern("to_i"), 0)), RVAL2GFLAGS(gdk_input_condition, GDK_TYPE_INPUT_CONDITION), (GdkInputFunction)exec_input, (gpointer)func)); G_RELATIVE2(self, func, id_relative_callbacks, id); return id; }
static void check_port(GtkButton *button, gpointer user_data) { gchar *valore; valore = gtk_editable_get_chars(GTK_EDITABLE(port_entry), 0, -1); chat_port = atoi(valore); g_free(valore); if (chat_port) { serv_sock = create_server_socket(); if (serv_sock != -1) { gtk_widget_destroy(GTK_WIDGET(user_data)); gdk_input_add(serv_sock, GDK_INPUT_READ, input_func, NULL); } } }
void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket *socket, GSocketEvent event) { GSocketGTKMutexProtected* guispecific = (GSocketGTKMutexProtected*)socket->m_gui_dependent; assert(guispecific != NULL); int c; if (socket->m_fd == -1) return; switch (event) { case GSOCK_LOST: /* fall-through */ case GSOCK_INPUT: c = 0; break; case GSOCK_OUTPUT: c = 1; break; case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break; default: return; } #if wxUSE_THREADS guispecific->m_mutex->Lock(); #endif gint current_id = guispecific->m_id[c]; guispecific->m_id[c] = -1; #if wxUSE_THREADS guispecific->m_mutex->Unlock(); #endif if (current_id != -1) { gdk_input_remove(current_id); } current_id = gdk_input_add(socket->m_fd, (c ? GDK_INPUT_WRITE : GDK_INPUT_READ), _GSocket_GDK_Input, (gpointer)socket); #if wxUSE_THREADS guispecific->m_mutex->Lock(); #endif guispecific->m_id[c] = current_id; #if wxUSE_THREADS guispecific->m_mutex->Unlock(); #endif }
static void client_attach (pid_t pid, int fd, struct server *s) { struct running_client *cl; cl = g_malloc0 (sizeof (struct running_client)); cl->pid = pid; cl->fd = fd; cl->tag = gdk_input_add (cl->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, (GdkInputFunction) client_input_callback, cl); cl->server = s; server_ref (s); debug (3, "client attached (pid:%d)", cl->pid); clients = g_slist_append (clients, cl); }
static void updatewrite(struct conduit *conduit) { struct data *data; data = conduit->cdata; if(data->fd < 0) return; if(dc_wantwrite()) { if(data->gdkwrite == -1) data->gdkwrite = gdk_input_add(data->fd, GDK_INPUT_WRITE, (void (*)(gpointer, int, GdkInputCondition))dcfdcb, conduit); } else { if(data->gdkwrite != -1) { gdk_input_remove(data->gdkwrite); data->gdkwrite = -1; } } }
static void main_frontend(int argc, char *argv[]) { GtkWidget *window, *vbox; gtk_init(&argc, &argv); gdk_rgb_init(); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "My WebCam"); gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL); gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(delete_event), NULL); gtk_signal_connect(GTK_OBJECT(window), "key_release_event", GTK_SIGNAL_FUNC(key_event), NULL); gtk_container_set_border_width(GTK_CONTAINER(window), 2); /* vertical box */ vbox = gtk_vbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(window), vbox); /* image */ drawing_area = gtk_drawing_area_new(); gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area), fmt.fmt.pix.width, fmt.fmt.pix.height); gtk_box_pack_start(GTK_BOX(vbox), drawing_area, FALSE, FALSE, 0); ctrl_create(vbox); gtk_widget_show_all(window); gdk_input_add(fd, GDK_INPUT_READ, frame_ready, NULL); printf("'g' grab an image - 'i' info toggle - 'q' quit\n"); gtk_main(); }
PRIVATE void clock_handler(AClock *clock, AClockReason reason) { Data *data = clock->gen->data; switch (reason) { case CLOCK_DISABLE: gdk_input_remove(data->input_tag); data->input_tag = -1; break; case CLOCK_ENABLE: if (data->input_tag == -1) data->input_tag = gdk_input_add(data->audiofd, GDK_INPUT_WRITE, (GdkInputFunction) gen_clock_mainloop, NULL); break; default: g_message("Unreachable code reached (esd_output)... reason = %d", reason); break; } }
gint c_gdk_input_add (gint s_fd, GdkInputCondition condition, EIF_OBJ object, EIF_PROC func, callback_data **p) { callback_data *cbd; eif_freeze (object); cbd = (callback_data *)g_malloc (sizeof (callback_data)); /* Return the pointer of the allocated block to Eiffel, so it can be deallocated later */ *p = cbd; cbd->rtn = func; cbd->obj = eif_access (object); return (gdk_input_add (s_fd, condition, c_gdk_input_function, cbd)); }
int display_connect(display_t *d) { struct sockaddr_un sun; int flags; if ( d->sock >= 0 ) return 0; /* Already connected */ /* Show desktop connection status */ display_desktop_show(d, DISPLAY_DESKTOP_CONNECTING); if ( (d->sock = socket(PF_UNIX, SOCK_STREAM, 0)) == -1 ) { error("socket: %s\n", strerror(errno)); return -1; } sun.sun_family = AF_UNIX; strcpy(sun.sun_path, d->sockname); if ( connect(d->sock, (struct sockaddr *) &sun, sizeof(struct sockaddr_un)) == -1 ) { error("connect(%s): %s\n", d->sockname, strerror(errno)); display_disconnect(d); return -1; } if ( (flags = fcntl(d->sock, F_GETFL, 0)) == -1 ) { error("fcntl(%s,F_GETFL): %s\n", d->sockname, strerror(errno)); display_disconnect(d); return -1; } if ( fcntl(d->sock, F_SETFL, O_NONBLOCK | flags) == -1 ) { error("fcntl(%s,F_SETFL): %s\n", d->sockname, strerror(errno)); display_disconnect(d); return -1; } d->sock_tag = gdk_input_add(d->sock, GDK_INPUT_READ, (GdkInputFunction) display_ctl_handler, d); return 0; }
int waitOutput() { int fd, count = 0; char c[2]; struct stat buf; my_mainwin = gui.mainwin; fd = open(f_oput, O_RDONLY | O_NONBLOCK); if (fd < 0) return QUIT; my_handler_id = gtk_signal_connect(GTK_OBJECT(my_mainwin), "event", GTK_SIGNAL_FUNC(handle_event), NULL); tag = gdk_input_add(fd, GDK_INPUT_READ, (GdkInputFunction) get_val, NULL); gtk_main(); close(fd); /* if (!access(f_ferr, F_OK)) { stat(f_ferr, &buf); if (buf.st_size > 0) return_val |= ERRN; } */ return return_val; }
static int connect(struct conduit *conduit) { struct data *data; pid_t pid; int pfd[2]; data = conduit->cdata; if(pipe(pfd)) return(-1); if((pid = fork()) < 0) { close(pfd[0]); close(pfd[1]); return(-1); } if(!pid) { int devnull; setpgrp(); if((devnull = open("/dev/null", O_RDWR)) < 0) exit(127); close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]); dup2(devnull, 0); close(devnull); /* Leave stderr as is */ execl("/bin/sh", "sh", "-c", SUBPROCCMD, NULL); exit(127); } close(pfd[1]); fcntl(pfd[0], F_SETFL, fcntl(pfd[0], F_GETFL) | O_NONBLOCK); data->subproc = pid; data->fd = pfd[0]; data->gdktag = gdk_input_add(pfd[0], GDK_INPUT_READ, (void (*)(gpointer, gint, GdkInputCondition))pipefdcb, conduit); data->inbufdata = 0; return(0); }
/** * c2_imap_init * @imap: IMAP object. * * This function will start an IMAP object, * it will connect the object, make it login, etc. * * Return Value: * 0 on success, -1 on failure. **/ gint c2_imap_init (C2IMAP *imap) { C2NetObjectByte *byte; gint i = 0; if(imap->mailboxes && !c2_net_object_is_offline(C2_NET_OBJECT(imap))) return 0; c2_mutex_lock(&imap->lock); if(!(byte = c2_net_object_run(C2_NET_OBJECT(imap)))) { imap->state = C2IMAPDisconnected; gtk_signal_emit(GTK_OBJECT(imap), signals[NET_ERROR]); c2_imap_set_error(imap, _("Error connecting to IMAP server.")); c2_mutex_unlock(&imap->lock); return -1; } imap->input_tag = gdk_input_add(byte->sock, GDK_INPUT_READ, (GdkInputFunction)c2_imap_on_net_traffic, imap); imap->state = C2IMAPNonAuthenticated; gtk_signal_connect(GTK_OBJECT(imap), "net_error", GTK_SIGNAL_FUNC(c2_imap_on_disconnect), NULL); gtk_signal_connect(GTK_OBJECT(imap), "logout", GTK_SIGNAL_FUNC(c2_imap_on_disconnect), NULL); do { if(imap->login(imap) < 0) { /* Login failed! */ const gchar *error; gchar *newuser, *newpass; error = c2_error_object_get (GTK_OBJECT (imap)); newuser = NULL; newpass = NULL; if (C2_IMAP_CLASS_FW (imap)->login_failed) { C2Mutex mylock; gint cont; c2_mutex_init (&mylock); c2_mutex_lock (&mylock); #ifdef USE_DEBUG if(_debug_imap) C2_PRINTD (MOD, "Executing login_failed\n"); #endif cont = C2_IMAP_CLASS_FW (imap)->login_failed (imap, error, &newuser, &newpass, &mylock); c2_mutex_lock (&mylock); #ifdef USE_DEBUG if(_debug_imap) printf ("login_failed returned %d!\n", cont); #endif c2_mutex_unlock (&mylock); c2_mutex_destroy (&mylock); if (cont) { g_free (imap->user); g_free (imap->pass); imap->user = newuser; imap->pass = newpass; } else { c2_error_object_set (GTK_OBJECT (imap), C2USRCNCL); break; } } } else imap->state = C2IMAPAuthenticated; } while (++i < 3 && imap->state != C2IMAPAuthenticated); if (imap->state != C2IMAPAuthenticated) return -1; g_print ("%s (%s@%s)\n", __PRETTY_FUNCTION__, imap->user, C2_NET_OBJECT (imap)->host); c2_mutex_unlock(&imap->lock); return 0; }
report_gui_t *report_gui_init(GtkWidget *window, report_gui_spot_tree_t *spot_tree_func, void *spot_tree_arg) { report_gui_t *rg; rg = (report_gui_t *) malloc(sizeof(report_gui_t)); rg->window = window; rg->total = lookup_widget(window, "report_total_value"); rg->significant = lookup_widget(window, "report_significant_value"); rg->executed = lookup_widget(window, "report_executed_slider"); rg->passed = lookup_widget(window, "report_passed_slider"); rg->failed = lookup_widget(window, "report_failed_slider"); rg->inconclusive = lookup_widget(window, "report_inconclusive_slider"); rg->skip = lookup_widget(window, "report_skip_slider"); rg->rtv_build = lookup_widget(window, "results_build_report"); gtk_object_set_data(GTK_OBJECT(rg->executed), "title", "Executed"); gtk_object_set_data(GTK_OBJECT(rg->passed), "title", "PASSED"); gtk_object_set_data(GTK_OBJECT(rg->failed), "title", "FAILED"); gtk_object_set_data(GTK_OBJECT(rg->inconclusive), "title", "INCONCLUSIVE"); gtk_object_set_data(GTK_OBJECT(rg->skip), "title", "Skipped"); /* Verdict list window activation */ rg->button_list[0] = lookup_widget(window, "results_verdicts"); rg->button_list[1] = lookup_widget(window, "tool_verdicts"); gtk_signal_connect_object(GTK_OBJECT(rg->button_list[0]), "activate", GTK_SIGNAL_FUNC(report_gui_list_clicked), rg); gtk_signal_connect_object(GTK_OBJECT(rg->button_list[1]), "clicked", GTK_SIGNAL_FUNC(report_gui_list_clicked), rg); /* Log viewer window activation */ rg->log = lookup_widget(window, "results_log"); rg->log2 = lookup_widget(window, "tool_log"); gtk_signal_connect(GTK_OBJECT(rg->log), "activate", GTK_SIGNAL_FUNC(report_gui_log_clicked), rg); gtk_signal_connect(GTK_OBJECT(rg->log2), "clicked", GTK_SIGNAL_FUNC(report_gui_log_clicked), rg); /* Report generation and viewer activation */ rg->rtv_view = lookup_widget(window, "results_view_report"); rg->rtv_view2 = lookup_widget(window, "tool_report"); gtk_signal_connect(GTK_OBJECT(rg->rtv_view), "activate", GTK_SIGNAL_FUNC(report_gui_view_clicked), rg); gtk_signal_connect(GTK_OBJECT(rg->rtv_view2), "clicked", GTK_SIGNAL_FUNC(report_gui_view_clicked), rg); gtk_signal_connect(GTK_OBJECT(rg->rtv_build), "activate", GTK_SIGNAL_FUNC(report_gui_build_clicked), rg); gtk_signal_connect(GTK_OBJECT(lookup_widget(window, "results_report_options")), "activate", GTK_SIGNAL_FUNC(report_gui_conf_clicked), rg); report_gui_sensitive(rg, 0); rg->tree = NULL; rg->out = NULL; rg->log_name = NULL; rg->report_name = NULL; /* Init Verdict List control */ rg->list.window = NULL; rg->list.view = NULL; rg->list.model = NULL; rg->list.spot_tree = NULL; rg->list.spot_log = NULL; rg->list.select_key = 0; rg->list.select_name = NULL; /* Init Log Viewer control */ report_gui_proc_clear(&(rg->log_viewer)); /* Init Report Config control */ report_gui_proc_clear(&(rg->report_conf)); /* Setup spot button handling */ rg->spot_tree_func = spot_tree_func; rg->spot_tree_arg = spot_tree_arg; /* Setup child termination handling */ rg->child_pipe[0] = -1; rg->child_pipe[1] = -1; rg->child_input = -1; rg->builder = NULL; rg->build_then_browse = 0; if ( pipe(rg->child_pipe) ) { fprintf(stderr, "Unable to create Report Generator pipe: %s", strerror(errno)); } else { /* Enable close-on-exec mode because it is an internal pipe */ fcntl(rg->child_pipe[0], F_SETFD, FD_CLOEXEC); fcntl(rg->child_pipe[1], F_SETFD, FD_CLOEXEC); rg->child_input = gdk_input_add(rg->child_pipe[0], GDK_INPUT_READ, (GdkInputFunction) report_gui_build_completed, rg); } /* Reset progress bars and their friends */ report_gui_reset(rg); return rg; }