int ConnSvr::OnInit() { if( GetConf()->msglensize() != 4 &&GetConf()->msglensize() != 2 ) { LOG_ERROR("msglensize can only 2 or 4"); return -1; } MsgHandleMgr::Init(); SEpollServer::SetSingleton(new EpollServer(InetAddress("0.0.0.0", m_config.port()), true)); SEpollServer::GetInstance()->Start(); LOG_ERROR("OnInit"); return 0; }
ret_ CNetworkHandle::OnMessage(const ub_1 *pMsg, size_ nSize, const TMsgInfo *pMsgInfo) { #ifdef _DEBUG_ if (!pMsg) return PARAMETER_NULL | PARAMETER_1; if (0 == nSize) return PARAMETER_ERROR | PARAMETER_2; if (!pMsgInfo) return PARAMETER_NULL | PARAMETER_3; #endif CNetworkConf *pConf = (CNetworkConf *)GetConf(); #ifdef _DEBUG_ if (!pConf) return NO_ELEMENT_IN_CONTAINER; #endif CPDUInfo *pPDUInfo = null_v; try { v_ CommandID((size_ *)(pMsg + pConf->GetCommandID()->Offset(pMsg, nSize))); ret_ Ret = pConf->IdentifyID(CommandID, pPDUInfo, DIRECTION_IN); if (SUCCESS != Ret) return Ret; } catch (error_code err) { return err; } TMU tmu; tmu.pPDUInfo = pPDUInfo; tmu.pMessage = (ub_1 *)pMsg; tmu.nSize = nSize; tmu.pMsgInfo = (TMsgInfo *)pMsgInfo; CContainer *pContainer = CUIManager::Instance()->GetCurContainer(); if (pContainer) pContainer->OnMessage(&tmu); return SUCCESS; }
ret_ CNetworkHandle::CheckSend(const CPDUInfo *pPDUInfo, const ub_1 *pMsg, size_ nSize) { #ifdef _DEBUG_ if (!pPDUInfo) return PARAMETER_NULL | PARAMETER_1; if (!pMsg) return PARAMETER_NULL | PARAMETER_2; if (0 == nSize) return PARAMETER_ERROR | PARAMETER_3; #endif CNetworkConf *pConf = (CNetworkConf *)GetConf(); #ifdef _DEBUG_ if (!pConf) return NO_ELEMENT_IN_CONTAINER; #endif // try { size_ *pnSize = (size_ *)(pMsg + pConf->GetSizeID()->Offset(pMsg, nSize)); *pnSize = nSize; } catch (error_code err) { return err; } // try { v_ CommandID((size_ *)(pMsg + pConf->GetCommandID()->Offset(pMsg, nSize))); ret_ Ret = pConf->IdentifyPDU(pPDUInfo, CommandID, DIRECTION_OUT); if (SUCCESS != Ret) return Ret; } catch (error_code err) { return err; } return SUCCESS; }
static void print_done(GtkPrintOperation *prt, GtkPrintOperationResult result, gpointer user_data) { GKeyFile *conf = GetConf(); GtkPrintSettings *settings = gtk_print_operation_get_print_settings(prt); #if GTK_CHECK_VERSION(2,12,0) GtkPageSetup *setup = gtk_print_operation_get_default_page_setup(prt); #endif if(!conf) return; #if GTK_CHECK_VERSION(2,12,0) Trace("Settings: %p Conf: %p page_setup: %p",settings,conf,setup); gtk_print_settings_to_key_file(settings,conf,NULL); gtk_page_setup_to_key_file(setup,conf,NULL); #else gtk_print_settings_foreach(settings,(GtkPrintSettingsFunc) SavePrintSetting,conf); #endif g_key_file_set_string(conf,"Print","Font",g_object_get_data(G_OBJECT(prt),"3270FontName")); }
int PrintText(const char *name, gchar *text) { GKeyFile *conf = GetConf(); GtkPrintOperation *prt; const gchar *font; GtkPageSetup *page_setup = NULL; GtkPrintSettings *print_settings = NULL; if(!text) return -EINVAL; prt = gtk_print_operation_new(); if(!prt) return -1; // Set job parameters g_object_set_data_full(G_OBJECT(prt),"3270Text",g_strsplit(g_strchomp(text),"\n",-1),(void (*)(gpointer)) g_strfreev); // Set print font = GetString("Print","Font",""); if(!*font) font = GetString("Terminal","Font","Courier"); g_object_set_data_full(G_OBJECT(prt),"3270FontName",g_strdup(font),g_free); // Configure print operation gtk_print_operation_set_job_name(prt,name); gtk_print_operation_set_allow_async(prt,0); gtk_print_operation_set_show_progress(prt,1); gtk_print_operation_set_custom_tab_label(prt,_( "Font" )); g_signal_connect(prt, "begin-print", G_CALLBACK(begin_print), 0); g_signal_connect(prt, "draw-page", G_CALLBACK(draw_page), 0); #ifdef HAVE_PRINT_FONT_DIALOG g_signal_connect(prt, "create-custom-widget", G_CALLBACK(create_custom_widget), 0); g_signal_connect(prt, "custom-widget-apply", G_CALLBACK(custom_widget_apply), 0); #endif g_signal_connect(prt, "done", G_CALLBACK(print_done), 0); if(conf) { #if GTK_CHECK_VERSION(2,12,0) gchar *ptr = g_key_file_get_string(conf,"Print Settings","output-uri",NULL); if(ptr) { gchar *uri = NULL; switch(*(ptr++)) { case '$': if(g_str_has_prefix(ptr,"home/")) uri = g_strdup_printf("file:///%s/%s",g_get_home_dir(),ptr+5); #if GTK_CHECK_VERSION(2,14,0) else if(g_str_has_prefix(ptr,"documents/")) uri = g_strdup_printf("file:///%s/%s",g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS),ptr+10); else if(g_str_has_prefix(ptr,"desktop/")) uri = g_strdup_printf("file:///%s/%s",g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP),ptr+8); #endif break; case '~': uri = g_strdup_printf("file:///%s/%s",g_get_home_dir(),ptr); break; } if(uri) { g_key_file_set_string(conf,"Print Settings","output-uri",uri); g_free(uri); } } print_settings = gtk_print_settings_new_from_key_file(conf,NULL,NULL); page_setup = gtk_page_setup_new_from_key_file(conf,NULL,NULL); if(!page_setup) page_setup = gtk_page_setup_new(); #else // GTK_CHECK_VERSION(2,12,0) print_settings = gtk_print_settings_new(); if(print_settings) { gchar **list; int f; list = g_key_file_get_keys(conf,"PrintSettings",NULL,NULL); if(list) { for(f=0;list[f];f++) gtk_print_settings_set(print_settings,list[f],g_key_file_get_string(conf,"PrintSettings",list[f],NULL)); g_strfreev(list); } } page_setup = gtk_page_setup_new(); #endif } else { page_setup = gtk_page_setup_new(); gtk_print_operation_set_print_settings(prt,gtk_print_settings_new()); } Trace("page_setup: %p print_settings: %p",page_setup,print_settings); gtk_print_operation_set_print_settings(prt,print_settings); gtk_print_operation_set_default_page_setup(prt,page_setup); // Run Print dialog gtk_print_operation_run(prt,GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,GTK_WINDOW(topwindow),NULL); g_object_unref(prt); return 0; }
bool Andigilog::start(IOService *provider) { int i; bool res; UInt8 cmd, data, addrs[] = ASC7621_ADDRS; /* Mapping common for Intel boards */ struct MList list[] = { { ASC7621_TEMP1H, ASC7621_TEMP1L, {"TC0D",TYPE_SP78,2,-1}, -1, 0, true }, { ASC7621_TEMP2H, ASC7621_TEMP2L, {KEY_AMBIENT_TEMPERATURE,TYPE_SP78,2,-1}, -1, 0, true }, { ASC7621_TEMP3H, ASC7621_TEMP3L, {KEY_DIMM_TEMPERATURE,TYPE_SP78,2,-1}, -1, 0, true }, { ASC7621_TEMP4H, ASC7621_TEMP4L, {KEY_CPU_HEATSINK_TEMPERATURE,TYPE_SP78,2,-1}, -1, 0, true }, { ASC7621_TACH1L, ASC7621_TACH1H, {"Fan 1",TYPE_FPE2,2,0}, true, 0, true }, { ASC7621_TACH2L, ASC7621_TACH2H, {"Fan 2",TYPE_FPE2,2,1}, true, 0, true }, { ASC7621_TACH3L, ASC7621_TACH3H, {"Fan 3",TYPE_FPE2,2,2}, true, 0, true }, { ASC7621_TACH4L, ASC7621_TACH4H, {"Fan 4",TYPE_FPE2,2,2}, true, 0, true } }; struct PList pwm[] = { { ASC7621_PWM1R, 0, -2 }, { ASC7621_PWM2R, 0, -2 }, { ASC7621_PWM3R, 0, -2 }, }; OSDictionary *conf = NULL, *sconf = OSDynamicCast(OSDictionary, getProperty("Sensors Configuration")), *dict; IOService *fRoot = getServiceRoot(); OSString *str, *vendor = NULL; char *key; char tempkey[] = "_temp ", /* Ugly hack to keep keys in order for auto-generated plist */ fankey[] = "tach "; res = super::start(provider); DbgPrint("start\n"); if (!(i2cNub = OSDynamicCast(I2CDevice, provider))) { IOPrint("Failed to cast provider\n"); return false; } i2cNub->retain(); i2cNub->open(this); for (i = 0; i < sizeof(addrs) / sizeof(addrs[0]); i++) if (!i2cNub->ReadI2CBus(addrs[i], &(cmd = ASC7621_VID_REG), sizeof(cmd), &data, sizeof(data)) && data == ASC7621_VID && !i2cNub->ReadI2CBus(addrs[i], &(cmd = ASC7621_PID_REG), sizeof(cmd), &data, sizeof(data)) && (data == ASC7621_PID || data == ASC7621A_PID)) { Asc7621_addr = addrs[i]; IOPrint("aSC7621 attached at 0x%x.\n", Asc7621_addr); break; } if (!Asc7621_addr) { IOPrint("Device matching failed.\n"); return false; } memcpy(&Measures, &list, sizeof(Measures)); memcpy(&Pwm, &pwm, sizeof(Pwm)); if (fRoot) { vendor = vendorID(OSDynamicCast(OSString, fRoot->getProperty("oem-mb-manufacturer") ? fRoot->getProperty("oem-mb-manufacturer") : (fRoot->getProperty("oem-manufacturer") ? fRoot->getProperty("oem-manufacturer") : NULL))); str = OSDynamicCast(OSString, fRoot->getProperty("oem-mb-product") ? fRoot->getProperty("oem-mb-product") : (fRoot->getProperty("oem-product-name") ? fRoot->getProperty("oem-product-name") : NULL)); } if (vendor) if (OSDictionary *link = OSDynamicCast(OSDictionary, sconf->getObject(vendor))) if(str) conf = OSDynamicCast(OSDictionary, link->getObject(str)); if (sconf && !conf) conf = OSDynamicCast(OSDictionary, sconf->getObject("Active")); i = 0; for (int s = 0, j = 0, k = 0; i < NUM_SENSORS; i++) { if (conf) { if (Measures[i].fan < 0) { snprintf(&tempkey[5], 2, "%d", j++); key = tempkey; } else { snprintf(&fankey[4], 2, "%d", k++); key = fankey; } if ((dict = OSDynamicCast(OSDictionary, conf->getObject(key)))) { str = OSDynamicCast(OSString, dict->getObject("id")); memcpy(Measures[i].hwsensor.key, str->getCStringNoCopy(), str->getLength()+1); if (Measures[i].fan > -1) Measures[i].hwsensor.pwm = ((OSNumber *)OSDynamicCast(OSNumber, dict->getObject("pwm")))-> unsigned8BitValue(); Measures[i].hwsensor.size = ((OSNumber *)OSDynamicCast(OSNumber, dict->getObject("size")))-> unsigned8BitValue(); str = OSDynamicCast(OSString, dict->getObject("type")); memcpy(Measures[i].hwsensor.type, str->getCStringNoCopy(), str->getLength()+1); } } if (Measures[i].hwsensor.key[0]) { if (Measures[i].fan < 0) { addSensor(Measures[i].hwsensor.key, Measures[i].hwsensor.type, Measures[i].hwsensor.size, s); s++; } else { if (!config.start_fan) config.start_fan = i; addTachometer(&Measures[i], Measures[i].fan = config.num_fan); config.num_fan++; } } } config.num_fan++; addKey(KEY_FAN_FORCE, TYPE_UI16, 2, 0); GetConf(); return res; }