DockModeClock::DockModeClock (DockModeWindowManager* dm, int zValue) : m_launchPoint(0) , m_appDesc (0) , m_dockWindow (0) { m_appDesc = ApplicationDescription::fromNativeDockApp (std::string ("com.palm.app.dockmodetime"), std::string (LOCALIZED("Time")), std::string ("1.0"), Settings::LunaSettings()->lunaSystemResourcesPath + std::string("/dockmode/time-icon-48x48.png"), // splashIcon std::string("Time"), // splashBackgroundName Settings::LunaSettings()->lunaSystemResourcesPath + std::string("/dockmode/time-icon-48x48.png"), // miniicon std::string("Palm"), std::string("http://www.palm.com"), std::string(LOCALIZED("Time"))); if (!m_appDesc) { g_warning ("appDesc could not be created"); return; } m_launchPoint = new LaunchPoint (m_appDesc, std::string ("com.palm.dockmodetime"), std::string ("com.palm.dockmodetime"), std::string (LOCALIZED("Time")), std::string (LOCALIZED("Time")), Settings::LunaSettings()->lunaSystemResourcesPath + std::string("/dockmode/time-icon-48x48.png"), // iconPath std::string(), // params false); const HostInfo& hostInfo = HostBase::instance()->getInfo(); QPixmap dockPixmap (hostInfo.displayWidth, hostInfo.displayHeight); // this will be replaced with the background pixmap m_dockWindow = new DockModeClockWindow (dockPixmap, dm, zValue); }
void ClockWindow::tick() { time_t rawTime; struct tm* timeinfo = 0; time(&rawTime); timeinfo = localtime(&rawTime); // get current local time if (m_twelveHour) { strftime(m_time, MaxTimeChars, LOCALIZED("%I:%M").c_str(), timeinfo); if (m_time[0] == '0') { memmove(m_time, m_time+1, MaxTimeChars-1); } } else { strftime(m_time, MaxTimeChars, LOCALIZED("%H:%M").c_str(), timeinfo); } // recalculate the width of the new time m_width = 0; int len = strlen(m_time); for (int i=0; i<len; i++) { QPixmap surf = m_digits[m_time[i]]; if (!surf.isNull()) m_width += surf.width(); } update(); }
void CWakeOnAccess::OnJobComplete(unsigned int jobID, bool success, CJob *job) { CMACDiscoveryJob* discoverJob = (CMACDiscoveryJob*)job; const std::string& host = discoverJob->GetHost(); const std::string& mac = discoverJob->GetMAC(); if (success) { CSingleLock lock (m_entrylist_protect); SaveMACDiscoveryResult(host, mac); } else { CLog::Log(LOGERROR, "%s - Mac discovery failed for host '%s'", __FUNCTION__, host.c_str()); if (IsEnabled()) { std::string heading = LOCALIZED(13033); std::string message = StringUtils::Format(LOCALIZED(13036).c_str(), host.c_str()); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, heading, message, 4000, true, 3000); } } }
void FullEraseConfirmationWindow::updateCountDownText() { if (m_secondsLeft == 1) { m_countDown = qFromUtf8Stl(LOCALIZED(kFullEraseCountDownSingular)); } else { m_countDown = qFromUtf8Stl(LOCALIZED(kFullEraseCountDownPlural)).arg(m_secondsLeft); } m_font.setPixelSize(kCountDownFontHeight); QFontMetrics metrics(m_font); m_countDownBounds = metrics.boundingRect(m_boundingRect.toRect(), Qt::AlignCenter|Qt::TextWordWrap, m_countDown); m_countDownBounds.moveTop(m_boundingRect.y() + (m_boundingRect.height() * countRatio)); }
void StatusBarClock::tick() { if(Settings::LunaSettings()->demoMode) return; time_t rawTime; struct tm* timeinfo = 0; ::time(&rawTime); timeinfo = ::localtime(&rawTime); // get current local time (or date) if(!m_displayDate) { // If local time matches we don't need to update anything if (timeinfo->tm_hour == m_lastUpdateTime.hour && timeinfo->tm_min == m_lastUpdateTime.min) { return; } m_lastUpdateTime.hour = timeinfo->tm_hour; m_lastUpdateTime.min = timeinfo->tm_min; if (m_twelveHour) { ::strftime(m_timeBuf, kMaxTimeChars, LOCALIZED("%I:%M").c_str(), timeinfo); if (m_timeBuf[0] == '0') { m_curTimeStr = m_timeBuf + 1; } else { m_curTimeStr = m_timeBuf; } } else { ::strftime(m_timeBuf, kMaxTimeChars, LOCALIZED("%H:%M").c_str(), timeinfo); m_curTimeStr = m_timeBuf; } setTimeText(m_curTimeStr); } else{ // If local time matches we don't need to update anything if (timeinfo->tm_year == m_lastUpdateTime.year && timeinfo->tm_mon == m_lastUpdateTime.month && timeinfo->tm_mday == m_lastUpdateTime.day) { return; } m_lastUpdateTime.year = timeinfo->tm_year; m_lastUpdateTime.month = timeinfo->tm_mon; m_lastUpdateTime.day = timeinfo->tm_mday; setTimeText(QDate::currentDate().toString(Qt::DefaultLocaleShortDate)); } update(); }
DockModeClockWindow::DockModeClockWindow(const QPixmap& pixmap, DockModeWindowManager* dm, int zValue) : DockModeWindow (WindowType::Type_DockModeWindow, pixmap) { setFlag (QGraphicsItem::ItemHasNoContents); setBoundingRect (pixmap.width(), pixmap.height()); setName (LOCALIZED("Time")); setAppId ("com.palm.dockmodetime"); QDeclarativeEngine* qmlEngine = WindowServer::instance()->declarativeEngine(); if(qmlEngine) { QDeclarativeContext* context = qmlEngine->rootContext(); Settings* settings = Settings::LunaSettings(); std::string systemMenuQmlPath = settings->lunaQmlUiComponentsPath + "DockModeTime/Clocks.qml"; QUrl url = QUrl::fromLocalFile(systemMenuQmlPath.c_str()); m_qmlNotifMenu = new QDeclarativeComponent(qmlEngine, url, this); if(m_qmlNotifMenu) { m_clockObject = qobject_cast<QGraphicsObject *>(m_qmlNotifMenu->create()); if(m_clockObject) { m_clockObject->setPos (boundingRect().x(), boundingRect().y()); m_clockObject->setParentItem(this); } } } }
static void ShowDiscoveryMessage(const char* function, const char* server_name, bool new_entry) { std::string message; if (new_entry) { CLog::Log(LOGINFO, "%s - Create new entry for host '%s'", function, server_name); message = StringUtils::Format(LOCALIZED(13035).c_str(), server_name); } else { CLog::Log(LOGINFO, "%s - Update existing entry for host '%s'", function, server_name); message = StringUtils::Format(LOCALIZED(13034).c_str(), server_name); } CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, LOCALIZED(13033), message, 4000, true, 3000); }
void BootupAnimation::generateUtf16AndGlyphOffsets() { m_textLine1 = convertToUtf16(LOCALIZED(s_line1)); m_textLine2 = convertToUtf16(LOCALIZED(s_line2)); m_glyphOffsetsLine1 = getGlyphOffsets(m_textLine1, s_fontHeight1); m_glyphOffsetsLine2 = getGlyphOffsets(m_textLine2, s_fontHeight2); m_widthLine1 = 0; for (unsigned int i = 0; i < m_glyphOffsetsLine1.size(); i++) m_widthLine1 += m_glyphOffsetsLine1[i]; m_widthLine2 = 0; for (unsigned int i = 0; i < m_glyphOffsetsLine2.size(); i++) m_widthLine2 += m_glyphOffsetsLine2[i]; }
void FullEraseConfirmationWindow::setupLabels() { QRect bounds = m_boundingRect.toRect(); m_title = qFromUtf8Stl(LOCALIZED(kFullEraseConfirmationTitle)); m_font.setPixelSize(kTitleFontHeight); QFontMetrics metrics(m_font); m_titleBounds = metrics.boundingRect(bounds, Qt::AlignCenter|Qt::TextWordWrap, m_title); m_titleBounds.moveTop(m_boundingRect.y() + (m_boundingRect.height() * titleRatio)); m_description = qFromUtf8Stl(LOCALIZED(kFullEraseConfirmationDescription)); m_font.setPixelSize(kDescriptionFontHeight); metrics = QFontMetrics(m_font); m_descBounds = metrics.boundingRect(bounds, Qt::AlignCenter|Qt::TextWordWrap, m_description); m_descBounds.moveTop(m_boundingRect.y() + (m_boundingRect.height() * descRatio)); updateCountDownText(); }
void CWakeOnAccess::SaveMACDiscoveryResult(const std::string& host, const std::string& mac) { CLog::Log(LOGNOTICE, "%s - Mac discovered for host '%s' -> '%s'", __FUNCTION__, host.c_str(), mac.c_str()); std::string heading = LOCALIZED(13033); for (EntriesVector::iterator i = m_entries.begin(); i != m_entries.end(); ++i) { if (StringUtils::EqualsNoCase(host, i->host)) { CLog::Log(LOGDEBUG, "%s - Update existing entry for host '%s'", __FUNCTION__, host.c_str()); if (!StringUtils::EqualsNoCase(mac, i->mac)) { if (IsEnabled()) // show notification only if we have general feature enabled { std::string message = StringUtils::Format(LOCALIZED(13034).c_str(), host.c_str()); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, heading, message, 4000, true, 3000); } i->mac = mac; SaveToXML(); } return; } } // not found entry to update - create using default values WakeUpEntry entry (true); entry.host = host; entry.mac = mac; m_entries.push_back(entry); CLog::Log(LOGDEBUG, "%s - Create new entry for host '%s'", __FUNCTION__, host.c_str()); if (IsEnabled()) // show notification only if we have general feature enabled { std::string message = StringUtils::Format(LOCALIZED(13035).c_str(), host.c_str()); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, heading, message, 4000, true, 3000); } SaveToXML(); }
static bool getLunaPrefSystemValue(const char* key, std::string& value) { #if defined(HAS_LUNA_PREF) char* str = 0; if (LP_ERR_NONE == LPSystemCopyStringValue(key, &str) && str) { value = str; g_free((gchar*) str); return true; } #endif value = LOCALIZED("Unknown"); return false; }
//virtual void PageTab::redoLabelTextLayout() { //TODO: somewhat wasteful. If there is no label, should just exit early and leave a layout that will be left unrendered by paint() m_textLayoutObject.clearLayout();; //TODO: Need a real fix later instead of localizing the labels at runtime QString m_tabLabelLocalized = fromStdUtf8(LOCALIZED(m_tabLabel.toStdString())); m_textLayoutObject.setText(m_tabLabelLocalized); // int fontSize = qBound(4,(int)((qreal)(m_labelMaxGeom.height())*0.5),24) -2; // fontSize = fontSize - (fontSize % 2); // m_textFont.setPixelSize(fontSize); m_textLayoutObject.setFont(m_textFont); QTextOption textOpts; textOpts.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); textOpts.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); m_textLayoutObject.setTextOption(textOpts); QFontMetrics textFontMetrics(m_textFont); int leading = textFontMetrics.leading(); int rise = textFontMetrics.ascent(); qreal height = 0; m_textLayoutObject.beginLayout(); while (height < m_labelMaxGeom.height()) { QTextLine line = m_textLayoutObject.createLine(); if (!line.isValid()) break; line.setLineWidth(m_labelMaxGeom.width()); if (m_textLayoutObject.lineCount() > 1) { height += leading; } line.setPosition(QPointF(0, height)); height += line.height(); } height = qMin((quint32)DimensionsGlobal::roundUp(height),(quint32)m_labelMaxGeom.height()); height = DimensionsGlobal::roundDown(height) - (DimensionsGlobal::roundDown(height) % 2); //force to an even # m_textLayoutObject.endLayout(); //TODO: PIXEL-ALIGN m_labelGeom = DimensionsGlobal::realRectAroundRealPoint(QSizeF(m_textLayoutObject.boundingRect().width(),height)).toAlignedRect(); }
bool CWakeOnAccess::WakeUpHost(const WakeUpEntry& server) { std::string heading = StringUtils::Format(LOCALIZED(13027).c_str(), server.host.c_str()); ProgressDialogHelper dlg (heading); { NetworkStartWaiter waitObj (m_netsettle_ms, server.host); // wait until network connected before sending wake-on-lan if (dlg.ShowAndWait (waitObj, m_netinit_sec, LOCALIZED(13028)) != ProgressDialogHelper::Success) { if (g_application.getNetwork().IsConnected() && HostToIP(server.host) == INADDR_NONE) { // network connected (at least one interface) but dns-lookup failed (host by name, not ip-address), so dont abort yet CLog::Log(LOGWARNING, "WakeOnAccess timeout/cancel while waiting for network (proceeding anyway)"); } else { CLog::Log(LOGNOTICE, "WakeOnAccess timeout/cancel while waiting for network"); return false; // timedout or canceled ; give up } } } { ULONG dst_ip = HostToIP(server.host); if (g_application.getNetwork().PingHost(dst_ip, server.ping_port, 500)) // quick ping with short timeout to not block too long { CLog::Log(LOGNOTICE,"WakeOnAccess success exit, server already running"); return true; } } if (!g_application.getNetwork().WakeOnLan(server.mac.c_str())) { CLog::Log(LOGERROR,"WakeOnAccess failed to send. (Is it blocked by firewall?)"); if (g_application.IsCurrentThread() || !g_application.m_pPlayer->IsPlaying()) CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, heading, LOCALIZED(13029)); return false; } { PingResponseWaiter waitObj (dlg.HasDialog(), server); // wait for ping response .. ProgressDialogHelper::wait_result result = dlg.ShowAndWait (waitObj, server.wait_online1_sec, LOCALIZED(13030)); if (result == ProgressDialogHelper::TimedOut) result = dlg.ShowAndWait (waitObj, server.wait_online2_sec, LOCALIZED(13031)); if (result != ProgressDialogHelper::Success) { CLog::Log(LOGNOTICE,"WakeOnAccess timeout/cancel while waiting for response"); return false; // timedout or canceled } } // we have ping response ; just add extra wait-for-services before returning if requested { WaitCondition waitObj ; // wait uninteruptable fixed time for services .. dlg.ShowAndWait (waitObj, server.wait_services_sec, LOCALIZED(13032)); CLog::Log(LOGNOTICE,"WakeOnAccess sequence completed, server started"); } return true; }
void DeviceInfo::gatherInfo() { Settings* settings = Settings::LunaSettings(); // Display information -------------------------------------------------------- m_screenDensity = 1.0f; m_hardwareScreenWidth = settings->displayWidth; m_hardwareScreenHeight = settings->displayHeight; m_screenWidth = (int) (m_hardwareScreenWidth / m_screenDensity); m_screenHeight = (int) (m_hardwareScreenHeight / m_screenDensity); int maxNegativeSpaceHeight = (int) (settings->maximumNegativeSpaceHeightRatio * m_screenHeight); m_maximumCardWidth = m_screenWidth; m_maximumCardHeight = m_screenHeight - settings->positiveSpaceTopPadding; m_minimumCardWidth = m_screenWidth; m_minimumCardHeight = m_screenHeight - settings->positiveSpaceTopPadding - maxNegativeSpaceHeight; m_touchableRows = (m_screenHeight - settings->positiveSpaceTopPadding - settings->positiveSpaceBottomPadding) / kTouchableHeight; // Platform Info -------------------------------------------------------------- getLunaPrefSystemValue("com.palm.properties.ProdSN", m_serialNumber); getLunaPrefSystemValue("com.palm.properties.DMCARRIER", m_carrierName); // If getLunaPrefSystemValue fails, such as luna-prefs not yet built for the platform, return // a sane version number for applications if(!getLunaPrefSystemValue("com.palm.properties.version", m_platformVersion)) { // This should only be returned if the luna-prefs package is not working, or // the luna-prefs system version has not been set. m_platformVersion = "3.5.0"; } else if (m_platformVersion.find("Palm webOS ", 0) != std::string::npos) { m_platformVersion = m_platformVersion.substr(11); } else if (m_platformVersion.find("HP webOS ", 0) != std::string::npos) { m_platformVersion = m_platformVersion.substr(9); } else if (m_platformVersion.find("Open webOS ", 0) != std::string::npos) { m_platformVersion = m_platformVersion.substr(11); } std::string platformVersion = m_platformVersion; size_t npos1 = 0, npos2 = 0; npos1 = platformVersion.find_first_of ('.'); if (npos1 != std::string::npos && npos1 <= platformVersion.size() - 1) npos2 = platformVersion.find_first_of ('.', npos1 + 1); if (npos1 == std::string::npos || npos2 == std::string::npos) { m_platformVersionMajor = m_platformVersionMinor = m_platformVersionDot = -1; } else { m_platformVersionMajor = atoi ((platformVersion.substr (0, npos1)).c_str()); m_platformVersionMinor = atoi ((platformVersion.substr (npos1+1, npos2)).c_str()); m_platformVersionDot = atoi ((platformVersion.substr (npos2+1)).c_str()); } // WIFI and bluetooth --------------------------------------------------------- std::string dummy; if (getLunaPrefSystemValue("com.palm.properties.WIFIoADDR", dummy)) m_wifiAvailable = true; else m_wifiAvailable = false; if (getLunaPrefSystemValue("com.palm.properties.BToADDR", dummy)) m_bluetoothAvailable = true; else m_bluetoothAvailable = false; // RadioType and carrier availability ----------------------------------------- gchar* buffer; gsize sz; int token = 0; if( !g_file_get_contents( "/dev/tokens/RadioType", &buffer, &sz, 0 ) ) { g_warning("RadioType token not found!"); m_radioType = 0; } else { token = atoi(buffer); g_free(buffer); m_radioType = token; } /* // Storage -------------------------------------------------------------------- getLunaPrefSystemValue("com.palm.properties.storageCapacity", dummy); if (!dummy.empty()) m_storageTotal = strtod(dummy.c_str(), NULL); else m_storageTotal = 0.0; */ // Keyboard configration ----------------------------------------------------- std::string hwName = HostBase::instance()->hardwareName(); if (hwName == "Desktop") { m_modelName = "Desktop"; m_modelNameAscii = "Desktop"; m_keyboardAvailable = true; m_keyboardSlider = false; m_coreNaviButton = true; m_keyboardType = "QWERTY"; m_swappableBattery = false; } else { if (!getLunaPrefSystemValue("com.palm.properties.deviceNameShortBranded", m_modelName)) m_modelName = "webOS smartphone"; if (!getLunaPrefSystemValue("com.palm.properties.deviceNameShort", m_modelNameAscii)) m_modelNameAscii = "webOS smartphone"; m_keyboardSlider = false; m_coreNaviButton = false; m_keyboardAvailable = false; m_swappableBattery = false; // Castle #if defined(MACHINE_CASTLE) if (hwName.find("Castle Plus", 0) != std::string::npos || hwName.find ("Roadrunner", 0) != std::string::npos) { m_keyboardSlider = true; m_coreNaviButton = false; m_swappableBattery = true; } else if (hwName.find("Castle", 0) != std::string::npos) { m_keyboardSlider = true; m_coreNaviButton = true; m_swappableBattery = true; } #endif #if defined(MACHINE_WINDSOR) if (hwName.find("Windsor", 0) != std::string::npos) { m_keyboardSlider = true; m_coreNaviButton = false; m_swappableBattery = true; } #endif #if defined(MACHINE_BROADWAY) if (hwName.find("Broadway", 0) != std::string::npos) { m_keyboardSlider = true; m_coreNaviButton = false; m_swappableBattery = false; } #endif #if defined(MACHINE_PIXIE) if (hwName.find("Pixie", 0) != std::string::npos) { m_keyboardSlider = false; m_coreNaviButton = false; m_swappableBattery = true; } #endif if (getLunaPrefSystemValue("com.palm.properties.KEYoBRD", dummy)) { m_keyboardAvailable = true; if (dummy == "z") m_keyboardType = "QWERTY"; else if (dummy == "w") m_keyboardType = "AZERTY"; else if (dummy == "y") m_keyboardType = "QWERTZ"; else if (dummy == "w1") m_keyboardType = "AZERTY_FR"; else if (dummy == "y1") m_keyboardType = "QWERTZ_DE"; else m_keyboardType = LOCALIZED("Unknown"); } else { m_keyboardAvailable = false; m_keyboardType = LOCALIZED("Unknown"); } } // Compose json string from the parameters ------------------------------- json_object* json = json_object_new_object(); json_object_object_add(json, (char*) "modelName", json_object_new_string(m_modelName.c_str())); json_object_object_add(json, (char*) "modelNameAscii", json_object_new_string(m_modelNameAscii.c_str())); json_object_object_add(json, (char*) "platformVersion", json_object_new_string(m_platformVersion.c_str())); json_object_object_add(json, (char*) "platformVersionMajor", json_object_new_int (m_platformVersionMajor)); json_object_object_add(json, (char*) "platformVersionMinor", json_object_new_int (m_platformVersionMinor)); json_object_object_add(json, (char*) "platformVersionDot", json_object_new_int (m_platformVersionDot)); json_object_object_add(json, (char*) "carrierName", json_object_new_string(m_carrierName.c_str())); json_object_object_add(json, (char*) "serialNumber", json_object_new_string(m_serialNumber.c_str())); json_object_object_add(json, (char*) "screenWidth", json_object_new_int(m_screenWidth)); json_object_object_add(json, (char*) "screenHeight", json_object_new_int(m_screenHeight)); json_object_object_add(json, (char*) "minimumCardWidth", json_object_new_int(m_minimumCardWidth)); json_object_object_add(json, (char*) "minimumCardHeight", json_object_new_int(m_minimumCardHeight)); json_object_object_add(json, (char*) "maximumCardWidth", json_object_new_int(m_maximumCardWidth)); json_object_object_add(json, (char*) "maximumCardHeight", json_object_new_int(m_maximumCardHeight)); json_object_object_add(json, (char*) "touchableRows", json_object_new_int(m_touchableRows)); json_object_object_add(json, (char*) "keyboardAvailable", json_object_new_boolean(m_keyboardAvailable)); json_object_object_add(json, (char*) "keyboardSlider", json_object_new_boolean(m_keyboardSlider)); json_object_object_add(json, (char*) "keyboardType", json_object_new_string(m_keyboardType.c_str())); json_object_object_add(json, (char*) "wifiAvailable", json_object_new_boolean(m_wifiAvailable)); json_object_object_add(json, (char*) "bluetoothAvailable", json_object_new_boolean(m_bluetoothAvailable)); json_object_object_add(json, (char*) "carrierAvailable", json_object_new_boolean(carrierAvailable())); json_object_object_add(json, (char*) "coreNaviButton", json_object_new_boolean(m_coreNaviButton)); json_object_object_add(json, (char*) "swappableBattery", json_object_new_boolean(m_swappableBattery)); json_object_object_add(json, (char*) "dockModeEnabled", json_object_new_boolean(true)); m_jsonString = json_object_to_json_string(json); json_object_put(json); }
QString SysmgrIMEModel::getLocalizedString(const std::string &str) { return fromStdUtf8(LOCALIZED(str)); }