Example #1
0
int main(int argc, char* argv[])
{
  if (argc < 6)
  {
    print_usage(argv[0]);
    return -1;
  }

  std::ofstream out ("ServiceDescription.h", std::ofstream::binary);

  std::ifstream version(argv[1], std::ios_base::in);
  std::ifstream license(argv[2], std::ios_base::in);
  std::ifstream methods(argv[3], std::ios_base::in);
  std::ifstream types(argv[4], std::ios_base::in);
  std::ifstream notifications(argv[5], std::ios_base::in);

  if (!(version && license && methods && types && notifications))
  {
    std::cout << "Failed to find one or more of version.txt, license.txt, methods.json, types.json or notifications.json" << std::endl;
    return -1;
  }

  out << "#pragma once" << std::endl;

  print_license(license, out);

  out << std::endl;

  out << "namespace JSONRPC" << std::endl;
  out << "{" << std::endl;
  out << "  const char* const JSONRPC_SERVICE_ID          = \"http://xbmc.org/jsonrpc/ServiceDescription.json\";" << std::endl;
  out << "  const char* const JSONRPC_SERVICE_VERSION     = \""; print_version(version, out); out << "\";" << std::endl;
  out << "  const char* const JSONRPC_SERVICE_DESCRIPTION = \"JSON-RPC API of XBMC\";" << std::endl;
  out << std::endl;

  out << "  const char* const JSONRPC_SERVICE_TYPES[] = {";
  print_json(types, out);
  out << "  };" << std::endl;
  out << std::endl;

  out << "  const char* const JSONRPC_SERVICE_METHODS[] = {";
  print_json(methods, out);
  out << "  };" << std::endl;
  out << std::endl;

  out << "  const char* const JSONRPC_SERVICE_NOTIFICATIONS[] = {";
  print_json(notifications, out);
  out << "  };" << std::endl;

  out << "}" << std::endl;

  return 0;
}
void Ut_DBusInterfaceNotificationSink::testSendingNotificationsToProxy()
{

    QList<Notification> notifications(createNotifications());
    gNotificationManagerStub->stubSetReturnValue("notifications", notifications);

    QList<NotificationGroup> groups;
    gNotificationManagerStub->stubSetReturnValue("groups", groups);

    sink->registerSink("service1", "path");

    QCOMPARE(gAddNotificationProxies.count(), 1);
}
void Ut_DBusInterfaceNotificationSink::testManagerNotDefined()
{
    delete sink;
    sink = new DBusInterfaceNotificationSink(NULL);
    QList<NotificationGroup> groups;
    gNotificationManagerStub->stubSetReturnValue("groups", groups);

    QList<Notification> notifications(createNotifications());
    gNotificationManagerStub->stubSetReturnValue("notifications", notifications);

    sink->registerSink("service1", "path");

    QCOMPARE(gNotificationManagerStub->stubCallCount("groups"), 0);
    QCOMPARE(gNotificationManagerStub->stubCallCount("notifications"), 0);
}
void LLNotificationsListener::listChannelNotifications(const LLSD& params) const
{
    LLReqID reqID(params);
    LLSD response(reqID.makeResponse());
    LLNotificationChannelPtr channel(mNotifications.getChannel(params["channel"]));
    if (channel)
    {
        LLSD notifications(LLSD::emptyArray());
        for (LLNotificationChannel::Iterator ni(channel->begin()), nend(channel->end());
             ni != nend; ++ni)
        {
            notifications.append(asLLSD(*ni));
        }
        response["notifications"] = notifications;
    }
    LLEventPumps::instance().obtain(params["reply"]).post(response);
}
Example #5
0
void ChatNotifier::notify(Notification *notification)
{
	if (!m_chatWidgetRepository)
		return;

	auto aggregateNotification = qobject_cast<AggregateNotification *>(notification);
	if (!aggregateNotification)
		return;

	auto latestNotification = aggregateNotification->notifications().last();

	auto buddies = BuddySet();
	auto chat = latestNotification->data()["chat"].value<Chat>();
	if (chat)
		buddies = chat.contacts().toBuddySet();

	for (auto chatWidget : m_chatWidgetRepository.data())
		// warning: do not exchange intersect caller and argument, it will modify buddies variable if you do
		if (buddies.isEmpty() || !chatWidget->chat().contacts().toBuddySet().intersect(buddies).isEmpty())
			sendNotificationToChatWidget(latestNotification, chatWidget);
}
Example #6
0
void AppManager::rescan()
{
    m_appList.clear();
    m_apps.clear();

    AppInfo settingsApp(QUuid(SETTINGS_APP_UUID), false, gettext("Settings"), gettext("System app"));
    m_appList.append(settingsApp.uuid());
    m_apps.insert(settingsApp.uuid(), settingsApp);
    AppInfo watchfaces(QUuid("18e443ce-38fd-47c8-84d5-6d0c775fbe55"), false, gettext("Watchfaces"), gettext("System app"));
    m_appList.append(watchfaces.uuid());
    m_apps.insert(watchfaces.uuid(), watchfaces);
    if (m_pebble->capabilities().testFlag(CapabilityHealth)) {
        AppInfo health(QUuid("36d8c6ed-4c83-4fa1-a9e2-8f12dc941f8c"), false, gettext("Health"), gettext("System app"), true);
        m_appList.append(health.uuid());
        m_apps.insert(health.uuid(), health);
    }
    AppInfo music(QUuid("1f03293d-47af-4f28-b960-f2b02a6dd757"), false, gettext("Music"), gettext("System app"));
    m_appList.append(music.uuid());
    m_apps.insert(music.uuid(), music);
    if(m_pebble->capabilities().testFlag(CapabilityWeather)) {
        AppInfo weather(WeatherApp::appUUID, false, gettext("Weather"), gettext("System app"), true);
        m_appList.append(weather.uuid());
        m_apps.insert(weather.uuid(), weather);
    }
    if(m_pebble->capabilities().testFlag(CapabilitySendSMS)) {
        AppInfo sendsms(SendTextApp::appUUID, false, SendTextApp::appName, gettext("System app"), true);
        m_appList.append(sendsms.uuid());
        m_apps.insert(sendsms.uuid(), sendsms);
    }
    AppInfo notifications(QUuid("b2cae818-10f8-46df-ad2b-98ad2254a3c1"), false, gettext("Notifications"), gettext("System app"));
    m_appList.append(notifications.uuid());
    m_apps.insert(notifications.uuid(), notifications);
    AppInfo alarms(QUuid("67a32d95-ef69-46d4-a0b9-854cc62f97f9"), false, gettext("Alarms"), gettext("System app"));
    m_appList.append(alarms.uuid());
    m_apps.insert(alarms.uuid(), alarms);
    AppInfo ticToc(QUuid("8f3c8686-31a1-4f5f-91f5-01600c9bdc59"), true, "Tic Toc", gettext("Default watchface"));
    m_appList.append(ticToc.uuid());
    m_apps.insert(ticToc.uuid(), ticToc);

    QDir dir(m_pebble->storagePath() + "/apps/");
    qDebug() << "Scanning Apps dir" << dir.absolutePath();
    Q_FOREACH(const QString &path, dir.entryList(QDir::Dirs | QDir::Readable)) {
        QString appPath = dir.absoluteFilePath(path);
        if (dir.exists(path + "/appinfo.json")) {
            scanApp(appPath);
        } else if (QFileInfo(appPath).isFile()) {
            scanApp(appPath);
        }
    }

    QSettings settings(m_pebble->storagePath() + "/apps.conf", QSettings::IniFormat);
    QStringList storedList = settings.value("appList").toStringList();
    if (storedList.isEmpty()) {
        // User did not manually sort the app list yet... We can stop here.
        return;
    }
    // Run some sanity checks
    if (storedList.count() != m_appList.count()) {
        qWarning() << "Installed apps not matching order config. App sort order might be wrong.";
        return;
    }
    foreach (const QUuid &uuid, m_appList) {
        if (!storedList.contains(uuid.toString())) {
            qWarning() << "Installed apps and stored config order cannot be matched. App sort order might be wrong.";
            return;
        }
    }
    // All seems fine, repopulate m_appList
    m_appList.clear();
    foreach (const QString &storedId, storedList) {
        m_appList.append(QUuid(storedId));
    }
Example #7
0
int main() {
    startup();
    updateUsers();
    loadSettings();
    while(!vars::accepted) {
        getmaxyx(stdscr, vars::maxY, vars::maxX);
        erase();
        firstNotice();
        if(!vars::running)
            break;
        refresh();
    }
    vars::noticeText.scroll = 0;
    while(vars::running) {//Main loop
        updateColors();
        updateUsers();
        if((vars::userList.at(vars::yourself).stat == 0) || ((!vars::chatting) && (!vars::banning)) || ((vars::about) && (!vars::settingsChangingDescription) && (!vars::settingsChangingNickname)))
            curs_set(0);
        else
            curs_set(1);
        getmaxyx(stdscr, vars::maxY, vars::maxX);
        erase();
        if((vars::maxX < 80) || (vars::maxY < 20)) {
            printw("The console window size is too small.\nPlease resize it to at least 80 * 20 width and height respectively.\nPress [Esc] or [Ctrl]+[C] to quit if resizing is not possible.");
            if(getch() == 27)
                vars::running = false;
        }
        else {
            printMainframe();
            if(vars::about)
                about();
            else {
                if(vars::menu == 0) {
                    notifications();
                    askUser();
                }
                else if(vars::menu == 1)
                    chatFrame();
            }
		}

        if((vars::previousState != 4) && (vars::previousState != vars::userList.at(vars::yourself).stat)) { //Check if your user stat changed
            curs_set(0);
            unsigned char thisState = vars::userList.at(vars::yourself).stat;
            if((vars::previousState > 0) && (thisState == 0)) {
                broadcast(std::vector < std::string >(1, "You have been banned!"), 6);
                vars::input.clear();
                vars::chattingWith.clear();
                vars::yourStr.clear();
                vars::menu = 0;
                vars::chatting = true;
                vars::chatScroll = -1;
                flushinp();
            }
            else if((vars::previousState == 0) && (thisState == 1))
                broadcast(std::vector < std::string >(1, "You have been unbanned!"), 8);
            else if((vars::previousState == 2) && (thisState == 1))
                broadcast(std::vector < std::string >(1, "You have been demoted!"), 6);
            else if((vars::previousState < 2) && (thisState == 2))
                broadcast(std::vector < std::string >(1, "You have been promoted to moderator!"), 8);
            broadcastWait(10);
        }
        else if(vars::broadcast.size() > 0) { //Or just draw a broadcast to the screen if there is one being sent.
            curs_set(0);
            broadcast(vars::broadcast, 6);
            vars::broadcast.clear();
            broadcastWait(10);
        }
        else {
            parseInput();
            refresh();
        }
        vars::previousState = vars::userList.at(vars::yourself).stat;
    }
    endwin();
    return 0;
}
uint8_t StatusClient::read()
{
    // Read the message type
    int32_t message_type;
    size_t bytes = _client.read((uint8_t *) &message_type, sizeof(message_type));
    if (bytes < 1) {
        Serial1.println("Error reading message type");
        return STATE_READ_ERROR;
    }

    // Decode message type as big-endian
    message_type = __REV(message_type);
    switch (message_type) {
      case MESSAGE_UPDATE:
        break;
      case MESSAGE_ERROR:
        Serial1.println("Upstream error");
        return STATE_UPSTREAM_ERROR;
      default:
        Serial1.print("Unknown message type ");
        Serial1.print(message_type, HEX);
        Serial1.println();
        return STATE_READ_ERROR;
    }

    // Read the message contents
    bytes = _client.read((uint8_t *) &_buffer, sizeof(NagiosStatus));
    if (bytes < sizeof(_buffer)) {
        Serial1.println("Error reading message contents");
        return STATE_READ_ERROR;
    }

    // Switch to little-endian values
    uint32_t *ptr = (uint32_t *) &_buffer;
    uint32_t *max_ptr = ptr + sizeof(NagiosStatus);
    for (; ptr < max_ptr; ++ptr)
        *ptr = __REV(*ptr);

    // Update the notification flags
    if (_buffer.critical_serial > _status.critical_serial)
        _notifications |= NOTIFICATION_CRITICAL;
    if (_buffer.warning_serial > _status.warning_serial)
        _notifications |= NOTIFICATION_WARNING;
    if (_buffer.ok_serial > _status.ok_serial)
        _notifications |= NOTIFICATION_OK;

    // Store the new status
    memcpy(&_status, &_buffer, sizeof(NagiosStatus));

    // Debug logging
    Serial1.print("New status: ");
    Serial1.print(criticalCount());
    Serial1.print(" ");
    Serial1.print(warningCount());
    Serial1.print(" ");
    Serial1.print(okCount());
    Serial1.print(", notifications: 0x");
    Serial1.print(notifications(), HEX);
    Serial1.println();

    return STATE_OK;
}