PRIVATE_EXTERN ipconfig_status_t manual_thread(ServiceRef service_p, IFEventID_t evid, void * event_data) { interface_t * if_p = service_interface(service_p); Service_manual_t * manual; ipconfig_status_t status = ipconfig_status_success_e; manual = (Service_manual_t *)ServiceGetPrivate(service_p); switch (evid) { case IFEventID_start_e: { ipconfig_method_data_t * method_data; method_data = (ipconfig_method_data_t *)event_data; if (manual) { my_log(LOG_DEBUG, "MANUAL %s: re-entering start state", if_name(if_p)); return (ipconfig_status_internal_error_e); } manual = malloc(sizeof(*manual)); if (manual == NULL) { my_log(LOG_ERR, "MANUAL %s: malloc failed", if_name(if_p)); status = ipconfig_status_allocation_failed_e; break; } ServiceSetPrivate(service_p, manual); bzero(manual, sizeof(*manual)); manual->ignore_link_status = method_data->manual.ignore_link_status; service_set_requested_ip_addr(service_p, method_data->manual.addr); service_set_requested_ip_mask(service_p, method_data->manual.mask); if (if_flags(if_p) & IFF_LOOPBACK) { /* set the new address */ (void)service_set_address(service_p, service_requested_ip_addr(service_p), service_requested_ip_mask(service_p), G_ip_zeroes); ServicePublishSuccessIPv4(service_p, NULL); break; } if (method_data->manual.router.s_addr != 0 && (method_data->manual.router.s_addr != method_data->manual.addr.s_addr)) { service_router_set_iaddr(service_p, method_data->manual.router); service_router_set_iaddr_valid(service_p); } manual->timer = timer_callout_init(); if (manual->timer == NULL) { my_log(LOG_ERR, "MANUAL %s: timer_callout_init failed", if_name(if_p)); status = ipconfig_status_allocation_failed_e; goto stop; } manual->arp = arp_client_init(G_arp_session, if_p); if (manual->arp == NULL) { my_log(LOG_NOTICE, "MANUAL %s: arp_client_init failed", if_name(if_p)); } my_log(LOG_DEBUG, "MANUAL %s: starting", if_name(if_p)); manual_start(service_p, IFEventID_start_e, NULL); break; } stop: case IFEventID_stop_e: { my_log(LOG_DEBUG, "MANUAL %s: stop", if_name(if_p)); if (manual == NULL) { break; } /* remove IP address */ service_remove_address(service_p); /* clean-up resources */ if (manual->arp) { arp_client_free(&manual->arp); } if (manual->timer) { timer_callout_free(&manual->timer); } if (manual) { free(manual); } ServiceSetPrivate(service_p, NULL); break; } case IFEventID_change_e: { change_event_data_t * change_event; ipconfig_method_data_t * method_data; if (manual == NULL) { my_log(LOG_DEBUG, "MANUAL %s: private data is NULL", if_name(if_p)); status = ipconfig_status_internal_error_e; break; } change_event = ((change_event_data_t *)event_data); method_data = change_event->method_data; change_event->needs_stop = FALSE; if (method_data->manual.addr.s_addr != service_requested_ip_addr(service_p).s_addr || (service_router_is_iaddr_valid(service_p) && (method_data->manual.router.s_addr != service_router_iaddr(service_p).s_addr)) || (method_data->manual.ignore_link_status != manual->ignore_link_status)) { change_event->needs_stop = TRUE; } else if (method_data->manual.mask.s_addr != service_requested_ip_mask(service_p).s_addr) { service_set_requested_ip_mask(service_p, method_data->manual.mask); (void)service_set_address(service_p, method_data->manual.addr, method_data->manual.mask, G_ip_zeroes); /* publish new mask */ ServicePublishSuccessIPv4(service_p, NULL); } break; } case IFEventID_arp_collision_e: { arp_collision_data_t * arpc; char msg[128]; arpc = (arp_collision_data_t *)event_data; if (manual == NULL) { return (ipconfig_status_internal_error_e); } if (arpc->ip_addr.s_addr != service_requested_ip_addr(service_p).s_addr) { break; } snprintf(msg, sizeof(msg), IP_FORMAT " in use by " EA_FORMAT, IP_LIST(&arpc->ip_addr), EA_LIST(arpc->hwaddr)); if (manual->user_warned == FALSE) { manual->user_warned = TRUE; ServiceReportIPv4AddressConflict(service_p, arpc->ip_addr); } my_log(LOG_ERR, "MANUAL %s: %s", if_name(if_p), msg); break; } case IFEventID_link_status_changed_e: { link_status_t link_status; if (manual == NULL) { return (ipconfig_status_internal_error_e); } if (manual->ignore_link_status) { break; } manual->user_warned = FALSE; link_status = service_link_status(service_p); if (link_status.valid == TRUE) { if (link_status.active == TRUE) { manual_start(service_p, IFEventID_start_e, NULL); } else { manual_cancel_pending_events(service_p); } } break; } case IFEventID_link_timer_expired_e: if (manual->ignore_link_status) { break; } manual_inactive(service_p); break; default: break; } /* switch */ return (status); }
//init all the basic elements of the window. Window::Window() { this->setWindowTitle("Sanajahti"); //init some text labels QLabel* label1 = new QLabel("Width:", this); label1->move(5, 10); QLabel* label2 = new QLabel("Height:", this); label2->move(80, 10); QLabel* label4 = new QLabel("Words", this); label4->move(3,68); //init textpanel for x length xpanel = new QLineEdit("4", this); xpanel->move(52, 4); xpanel->setFixedWidth(25); xpanel->setValidator(new QIntValidator(1, 99, this)); connect(xpanel, SIGNAL(textChanged(const QString &)), this, SLOT(gridChange())); //init textpanel for y length ypanel= new QLineEdit("4", this); ypanel->move(132, 4); ypanel->setFixedWidth(25); ypanel->setValidator(new QIntValidator(1, 99, this)); connect(ypanel, SIGNAL(textChanged(const QString &)), this, SLOT(gridChange())); //init textpanel for library path library_path = new QLineEdit("", this); library_path->move(5, 33); library_path->setFixedWidth(90); library_path->setReadOnly(true); library_path->setStyleSheet("background-color:lightgrey"); //init button to select library browse_button = new QPushButton("Library", this); browse_button->move(95, 34); browse_button->setFixedWidth(65); connect(browse_button, SIGNAL(clicked()), this, SLOT(browse())); //init startbutton start_button = new QPushButton("Start", this); start_button->move(3, 91); start_button->setFixedWidth(58); connect(start_button,SIGNAL(clicked()), this, SLOT(manual_start())); restart_button = new QPushButton("Restart", this); restart_button->move(3, 91); restart_button->setFixedWidth(58); restart_button->setHidden(true); connect(restart_button, SIGNAL(clicked()), this, SLOT(restart())); //init button for adb controlling adb_button = new QPushButton("Auto Solve", this); adb_button->move(62, 91); connect(adb_button, SIGNAL(clicked()), this, SLOT(adb_start())); //init combobox for wordlist list = new QComboBox(this); list->move(52,62); list->setFixedWidth(105); list->setDisabled(true); connect(list, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(drawWord(const QString &))); //init mapper for pairing tile textChanged() signals to widget calling it mapper = new QSignalMapper(this); connect(mapper, SIGNAL(mapped(int)), this, SLOT(valueChanged(int))); path=QDir::currentPath(); //call function to create 4x4 grid makeGrid(4,4); }