Ticket #5319: mythtv-5319-add_query_timezone_to_protocol.patch

File mythtv-5319-add_query_timezone_to_protocol.patch, 2.3 KB (added by sphery <mtdean@…>, 12 years ago)

main patch

  • programs/mythbackend/mainserver.h

     
    135135    void HandleQueryLoad(PlaybackSock *pbs);
    136136    void HandleQueryUptime(PlaybackSock *pbs);
    137137    void HandleQueryMemStats(PlaybackSock *pbs);
     138    void HandleQueryTimezone(PlaybackSock *pbs);
    138139    void HandleBlockShutdown(bool blockShutdown, PlaybackSock *pbs);
    139140   
    140141    void SendResponse(MythSocket *pbs, QStringList &commands);
  • programs/mythbackend/mainserver.cpp

     
    1515#include <math.h>
    1616#include <unistd.h>
    1717#include <fcntl.h>
     18#include <time.h>
    1819#include "../../config.h"
    1920#ifdef HAVE_SYS_SOUNDCARD_H
    2021    #include <sys/soundcard.h>
     
    374375    {
    375376        HandleQueryMemStats(pbs);
    376377    }
     378    else if (command == "QUERY_TIMEZONE")
     379    {
     380        HandleQueryTimezone(pbs);
     381    }
    377382    else if (command == "QUERY_CHECKFILE")
    378383    {
    379384        HandleQueryCheckFile(listline, pbs);
     
    23102315
    23112316/**
    23122317 * \addtogroup myth_network_protocol
     2318 * \par        QUERY_TIMEZONE
     2319 * Returns timezone offset, timezone name
     2320 */
     2321void MainServer::HandleQueryTimezone(PlaybackSock *pbs)
     2322{
     2323    MythSocket    *pbssock = pbs->getSocket();
     2324    QStringList strlist;
     2325    QString offset("UNDEF");
     2326    QString name("UNDEF");
     2327
     2328#ifndef USING_MINGW
     2329    char zone_string[64];
     2330    time_t t;
     2331    struct tm *result = (struct tm *)malloc(sizeof(*result));
     2332
     2333    t = time(NULL);
     2334    localtime_r(&t, result);
     2335
     2336    if (result != NULL)
     2337    {
     2338        if (strftime(zone_string, sizeof(zone_string), "%z", result) > 0)
     2339            offset = zone_string;
     2340        if (strftime(zone_string, sizeof(zone_string), "%Z", result) > 0)
     2341            name = zone_string;
     2342    }
     2343
     2344    if (result != NULL)
     2345        free(result);
     2346
     2347#endif
     2348    strlist << offset << name;
     2349
     2350    SendResponse(pbssock, strlist);
     2351}
     2352
     2353/**
     2354 * \addtogroup myth_network_protocol
    23132355 * \par        QUERY_CHECKFILE \e checkslaves \e programinfo
    23142356 */
    23152357void MainServer::HandleQueryCheckFile(QStringList &slist, PlaybackSock *pbs)