~ubuntu-branches/ubuntu/precise/mythtv/precise

« back to all changes in this revision

Viewing changes to mythtv/libs/libmythbase/mythcommandlineparser.cpp

  • Committer: Package Import Robot
  • Author(s): Mario Limonciello
  • Date: 2012-03-05 21:49:35 UTC
  • mfrom: (1.1.78)
  • Revision ID: package-import@ubuntu.com-20120305214935-vxn0sv24s35dl1sw
Tags: 2:0.25.0~master.20120305.6519666-0ubuntu1
* Drop mythtv-themes metapackage and childish theme.  Should be installed
  exclusively through theme chooser now.
* Update Mythbuntu theme git links to still create that theme package.
* Update configure without install patch.
* Tweak default max_connections for mysql to be 100 per requests from
  mythtv mailing lists.
* Update to a checkout post mythtv 0.25 beta release.
* New upstream checkout (6519666)
* >>Upstream changes since last upload (532cee8):
* [6519666] Use deleteLater() when deleting server sockets in
  ServerPool.
* [b08b41b] Silence unused variable warning
* [5112e25] Silence unused variable warning
* [40c69e1] AvFormatDecoder: add FORCE_DTS_TIMESTAMPS environment
  variable
* [dbb5ffb] Merge branches 'master' and 'master' of
  github.com:MythTV/mythtv
* [57687c8] Subtitles: Initialize the SRT error count to avoid bogus
  diagnostics.
* [6c3a799] Increase kMaxUIWaitTime to 10 seconds. The theory is that
  this timeout was to prevent a very delayed response to an
  availability check causing playlists to resume playing long after
  the user had moved on. The present timeout was very short though and
  didn't account for delays caused by disks needing to be spun up or
  just the latency of checking multiple storage groups for a file.
  Almost certainly fixes #8316
* [dd9a92a] Subtitles: Fix a null pointer dereference when splitting
  long lines.
* [5f98ce1] Fixes #10367. Adds new Motorolla DCX-3200 vendor and
  device id.
* [7347bf5] Fix for WSDL generation.
* [a454b79] Allow the processing of uncompressed data from Schedules
  Direct.
* [f19c9c2] Minor changes to allow compilation using VS2010
* [0607b58] Fix build after [6a200130eff4]
* [6a20013] Handle more ISO-639 codes
* [d1a6cc8] Fix universal package build with new osx-builder
* [20f2c45] Fix UPnP for Sony BluRay players
* [638192e] mythtranscode: --fifoinfo reports aspect ratio of first
  uncut frame
* [18fdd67] Look in more than one location for libdvdcss on mac.
* [871a1cd] Giving up on Qt, doing it with an external command.
* [4392c16] Delay first call to QTextCodec until after main
  QApplication has been created
* [da7626e] Do not disable mythmusic dependencies when using --
  disable-all
* [ca996e0] Updated Norwegian Bokmal MythFrontend and all plugins
  translation from Rune Evjen.
* [18ab21a] Rearrange code in AddRangeList to defeat compile warnings
* [2422b6f] Miscellaneous string fixes
* [5e898a1] Fix HLS AddVideoLiveStream with files in subdirectories.
* [f834940] MythArchive: Remove the Cancel options from the menus
* [366d96d] Correct issue passing python library name for dependency
  checking.
* [c09418f] MythBrowser: Remove the Cancel options from the menus
* [002d7c5] MythMusic: Remove the Cancel options from the menus
* [bb3d1a8] MythMusic: Add some context menus on the playlist editor
  screen
* [bf4ff78] Per 2075458f5 Remove deprecated attribute from
  dispatchNow(), we know it's deprecated but it's not going away any
  time soon
* [12bbcf0] Fix a warning about an unused variable in httpconfig.cpp
* [43dcfce] Fix a warning about an unused variable in videolist.cpp
* [4edcda6] Move the Recording Profiles editor into mythtv-setup where
  it belongs. This constantly gets overlooked because it's not in the
  right place, especially by users who chose to use a third party
  frontend.
* [d7c8dfb] Better default device (when MediaMonitor disabled) on OS
  X. Refs #10370
* [7b526c4] Rework AudioReencodeBuffer further to fix HLS audio
  buffering
* [a130e74] Bump ABI version.
* [5e976b4] Rename util.h into mythmiscutil.h
* [efe385c] Fix dcraw detection on FreeBSD (old sh, not bash)
* [f5aa5e8] Use QNetworkAddressEntry to get proper broadcast address
  for udplistener
* [b6f9e1d] Revert "Rename util.h into mythutil.h"
* [84275f1] Revert "util.h rename itself didn't get committed"
* [8ef8c0b] Merge branch 'master' of github.com:MythTV/mythtv
* [0fe6e14] Totally rework the AudioReencodeBuffer part in transcode
* [fb8004a] util.h rename itself didn't get committed
* [ef771da] Rename util.h into mythutil.h
* [ba9b5d3] Rewrite configure for mythplugins
* [a5557a3] Fix MythZoneMinder on mac; the proper way..
* [30ed8f0] DeleteMap tracker: Fix an error in 94d27c67f.
* [6ae9f66] Rewrite configure for mythplugins
* [0fc9853] Fix MythZoneMinder on mac; the proper way..
* [79f5133] Updated US English MythFrontend and all plugins
  translation from the US English Language Translation Team.
* [6952dc4] Miscellaneous typo and case fixes.
* [b85f5bb] MythArchive: various minor mythburn.py script improvements
* [7e9cd56] Missed a change from cda7871f - I forgot to make install
  when testing and missed the breakage.
* [9d83307] Remove an errant <value> tag from the mythgallery default
  theme. This was causing some confusion for translators.
* [cda7871] Fix the channel icon not loading in the OSD on remote
  frontends by switching to using the channel icon storage group. This
  bug has been around for years so it's nice to finally have a fix.
* [e0e321f] Additional case and spacing fixes.
* [47c7c48] Add a few missing spaces...
* [736524b] Various case and punctuation fixes.
* [eba28f4] MythMusic: Only abort ripping upon confirmation
* [81acf24] Tweak the space available for the channel number so that
  it remains hidden behind the poster.
* [fbba2ae] Show coverart in the Terra OSD, falling back to channel
  icon if the artwork isn't available and channel number if the
  channel icon isn't available.
* [ff4d601] DVD navigation: Reenable skipping past the last chapter of
  a title, and skipping previous to the first chapter of a title.  The
  limitation may have been left over from an older version of
  libdvdnav.
* [8ea557a] Fix 'depends'. I'm surprised I didn't notice this earlier,
  perhaps because I was using <group> a lot I missed that depends
  behaviour didn't work for immediate children of <window>.
* [eb87f9e] Fix 'depends' for inherited and copied screens.
* [38221b8] Only show poster in the default-wide OSD when we're not
  displaying the channum/icon/callsign. Also center the poster better
  in the available space.
* [69cae58] Merge commit 'e965387441ff189bb2c096f8ed5bdbf2b2a473e6'
* [e965387] Add setup script and readme
* [905e8e5] Split 'mythtv/bindings/python/MythTV/tmdb3/' into commit
  '565041dddf9d4937c31c0d57475c548e56882e89'
* [565041d] Enable search paging for TMDB v3 API.
* [367b05d] Enable search paging for TMDB v3 API.
* [6113151] Add proper language support to TMDB v3 API.
* [6410395] Add proper language support to TMDB v3 API.
* [c65d8eb] Remove TMDB API key from request.py
* [6c4c60a] Remove TMDB API key from request.py
* [b38f901] Fix some null strings in SQL inserts on NOT NULL columns.
* [55fd3bf] MythUI: Make ascent/descent/bearing adjustment a little
  easier to follow, by using moveTop/moveLeft instead of setX/setY
* [d16575c] MythUI: fix a typo in MythUIText::DrawSelf that could
  result in an incorrect canvas size.
* [64383c5] Fix a compiler warning.
* [ecea05d] Added ENO to an error log in avformatdecoder
* [03e2387] Services API: Fix cut and paste error.
* [99abdfe] Update xml schema declaration for 0.25
* [6e2f231] Fix typo
* [05e5cf7] Updated Spanish/Spain MythFrontend, MythArchive,
  MythBrowser, MythGallery, MythGame, MythMusic, MythNetvision,
  MythNews, MythWeather transation from the Spanish Language
  Translation Team
* [2f895cb] Fix mythzoneminder on mac part #3
* [e34c8d7] Fix universal architecture compilation of myth on mac.
* [a513779] Fix MythZoneMinder part #2
* [700a58d] Remove stray include, same as <Qt>
* [d84d5c9] Add basic dead key support to mythuitextedit. Implemented
  from scratch because I couldn't see a way of getting QT to handle
  it. 
* [c3544ed] Fix mac compilation
* [6bfda0c] Fix mythoneminder compilation when using mysql universal
  libraries.
* [21ad34b] Add --firewire-sdk configuration switch to configure
* [3196c2c] Fix FireWire compilation on mac when compiling in 64 bits
  mode.
* [5dccbd5] Fix mac compilation when Qt Frameworks are in use.
* [20d6852] Fix libcec configure to work with v1.5
* [f16048b] Finish the db upgrade to 1299 (perl bindings)
* [d486b8a] Make artwork edit UI elements optional on video metadata
  edit screen.
* [38dfa89] Updated British English MythFrontend, MythArchive,
  MythGame and MythMusic translation from Nick Morrott
* [7e4740e] Refs #8941. Make sure we set the channum when switching to
  a new card with either a specific chanid or inputid.
* [05bc5e1] plugins configure: Remove some debugging left by mistake
* [ff593fa] Clean up the mappings for network control jump points.
* [146ee76] Fixes #8744. Fixes crash in DVB-x channel scanning.
* [6f24f3b] Subtitles: Rename the OSDSubFont setting to
  DefaultSubtitleFont.
* [6202c0d] Revert "Subtitles: Remove the OSDSubFont setting."
* [4a2420e] MythZoneMinder: Add support for the deep filesystem
  hierarchy for events.
* [a6b1e3a] Program editor: don't seek too far when stepping to the
  next keyframe.
* [97da8c8] Fix a doxygen comment
* [144c8bb] MythMusic: Do a full reload of the tracks and playlists
  after doing a scan
* [f78f999] Change delete behaviour so that we always use the deleted
  recording group allowing all recordings to be undeleted. By default
  we will only keep recordings for a minimum of 5 minutes (max ~20m)
  after their deletion, enough time to recover from a mistake but
  still free up space quickly. As before the user can specify to keep
  deleted recordings for a fixed number of days or until the space is
  needed for a new recording instead. Post 0.25 this change will allow
  us to strip out the old deletion code and simplify configuration
  process, the functional change is being made now to fix a couple of
  bugs caused by external processes such as MythPreviewGen blocking
  deletes from the UI. Fixes #9536
* [cfd3fc0] MythMusic: Fix the sending of the MUSIC_SETTINGS_CHANGED
  event
* [5932419] Merge branch 'compartist'
* [5206271] Subtitles: Apply OSDCC708TextZoom to CEA-608 captions as
  well.
* [99512fb] Refs #10386.  Don't sent EXIT_TO_MAIN event to Live TV
  jump point.
* [dfd909f] Fix crash on mac when no audio device exists.
* [bd68156] MythMusic: Fix the BLANKSCR keybinding not working
* [9016890] MythMusic: Check for some additional cdio headers
* [3570a99] MythMusic: Fix a memory leak in the playlist editor
* [7e6f5fa] Fixes #10386. Segfault fix. Check for null.
* [510da69] As noted in SHA1:9551bce2, MainServer doesn't know the
  actual recording status because it defaults to rsRecorded when the
  recordinginfo is initialized from the recorded table.  MainServer
  doesn't account for this and tries to make any needed state change
  which always ends up staying rsRecorded.  MainServer then passes
  this bad status to the scheduler.  If the recording had already
  failed, the rsFailed status gets overwritten.
* [3740d7d] Spelling consistency fixes
* [47d7c77] Fixes #9233. Refs #7408. Re-enables WindowResized().
* [a5447f1] MythMusic: Add a Compilations branch to the playlist
  editor
* [1824969] Fixes #10153. Guess at DVB-S vs DVB-S2 when not explicitly
  set.
* [21784ce] Fixes #10377. Prevent getting "stuck on a mux".
* [593d24b] Refs #10377. Some logging fixes. (VB_PLAYBACK-
  >VB_CHANNEL).
* [14ec737] Change the rsTuning UI state equivalent from 'tuning' to
  'running'. The UI states for the 'status' statetype are limited to 5
  generic values (normal, running, warning, error, disabled) to allow
  some portability to scenarios other than recording. (This was
  supposed to save themers some time and effort although it also binds
  their hands and doesn't allow as much creativity with how various
  recording states are represented. For this reason it may be re-
  visited post-0.25)
* [4d68d5e] Updated Russian MythFrontend, MythArchive, MythBrowser,
  MythGallery, MythGame, MythMusic, MythNews, MythWeather and
  MythZoneminder.
* [34c8767] Subtitles: fix an incorrect CEA-708 font mapping.
* [b967448] Fix the faulty exit code 139 issue in Ubuntu systems
* [723d798] Subtitles: improve vertical alignment for CEA-608
  captions.
* [1af1aec] Fixes display of position in the Program Lister.
  MythUIButtonList is zero indexed, to get a position for display we
  must add one.
* [967208b] Fix the last, hopefully, remaining places where
  livetvorder isn't honored.
* [0a301c0] Fix the scheduler to not write incorrect oldrecorded
  entries.
* [5d5aef3] Subtitles: improve the layout.
* [878d5eb] String consistency updated
* [456bb42] Updated Estonian MythFrontend and all plugins translation
  from Marko Punnar
* [e719d54] Replace tabs with spaces in Terra's schedule filter editor
  window xml
* [a3d9891] Use proper capitalization for some common words and
  prefixes.
* [5b19c4d] Populate the infomap from both RecordingRule and
  RecordingInfo if available. This fixes recording rule specific
  information not being available in the sub screens of the schedule
  editor.
* [f77d001] Fix minor problems editing in-progress recordings.
* [006ded1] Fix recording status strings being set to 'Not scheduled'
  when the reason for that is they were in the past and should have
  been marked as Recorded/Aborted/Failed/Cancelled/etc instead
* [6bedf81] Correct handling of unrelated argument after arg-less
  keyword.
* [7adbd54] Delay String processing until after QApplication has been
  initialized.
* [f613a43] Fix LiveTV switching by videosource to honor livetvorder.
* [9b5b7b5] Exit cutlist edit mode cleanly when executing a jump
  point.
* [c2a0b85] Updated British English translation MythFrontend
  translation from Nick Morrott.
* [307dac8] Make jump points work during playback when the OSD is
  present.
* [d59f4f4] Change dynamic cast to static. This is troubling because
  we rely on dynamic casts in so many places but for at least one
  person this cast was failing and causing popup menus in MythMusic to
  no longer have any effect. Maybe a buggy version of gcc?
* [3de87c3] Subtitles: Fix a logic error.
* [23d5167] Make host checks in Video Library scanner case
  insensitive.
* [5d7c01d] Cutlist editor: Update the edit bar for in-progress
  recordings.
* [1ce3d21] Cutlist editor: Adjust "Cut to End" behavior for an in-
  progress recording.
* [4a8546d] Merge branch 'master' of github.com:MythTV/mythtv
* [1d6485d] MythArchive consistency fixes.
* [89c34ef] Fix seeking backwards into a cut region.
* [6c3b564] Updated British English translation MythFrontend
  translation from Nick Morrott.
* [5501fff] Fix long-standing bug that always cleared
  record.next_record instead of updating it.
* [0c5de8e] Add missing menu closed event when closing the menu via
  the mouse. Fixes the menu dialog not working in some screens after
  being dismissed using a right click.
* [93c228d] Prevent crash when invoking the menu dialog via the right
  mouse button in Watch Recordings. ShowMenu() is a virtual method in
  MythScreenType, it's intended purpose is to load/display the context
  menu but here it is displaying a menu loaded elsewhere with no
  guards against duplicate popups being created. Move the menu display
  code to DisplayPopupMenu(), restore ShowMenu() to behave the same as
  the MENU key binding and re-instate the guards against multiple menu
  dialogs being created. Also fixes #10248 - 'Cannot delete recording
  if file is missing'
* [b755eca] Attempt to prevent a QString segfault if MythMenu changes
  while a dialog is open.
* [f3efafe] Fix segfault in MythUIButtonTree when list is empty and we
  attempt to navigate it. Refs #9101
* [b3e44a2] Rule type was missed from the RecordingRule text map.
  Added so that it appears twice in the map, once under the correct
  title of ruletype but also as rectype to be consistent with the
  ProgramInfo map until after 0.25 when we can rename that instance.
* [2075458] Remove deprecated attribute from dispatchNow(), we know
  it's deprecated but it's not going anywhere soon.
* [82fc1af] Add Collection support to developmental tmdb3 grabber.
* [0f0b0a7] Better backend metaclass, and people search support.
* [c47940a] Clean up and document background machinery
* [850fbc2] Replacement PagedList to temporarily work around bug in
  search API
* [d13addf] Add caching to tmdbv3 requests.
* [fe97f23] In progress TMDB v3 grabber script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
#include "mythlogging.h"
59
59
#include "mythversion.h"
60
60
#include "logging.h"
61
 
#include "util.h"
 
61
#include "mythmiscutil.h"
62
62
 
63
63
#define TERMWIDTH 79
64
64
 
143
143
 */
144
144
CommandLineArg::CommandLineArg(QString name, QVariant::Type type,
145
145
                   QVariant def, QString help, QString longhelp) :
146
 
    ReferenceCounter(), m_given(false), m_name(name), m_group(""),
147
 
    m_deprecated(""), m_type(type), m_default(def), m_help(help),
 
146
    ReferenceCounter(), m_given(false), m_converted(false), m_name(name),
 
147
    m_group(""), m_deprecated(""), m_type(type), m_default(def), m_help(help),
148
148
    m_longhelp(longhelp)
149
149
{
 
150
    if ((m_type != QVariant::String) && (m_type != QVariant::StringList) &&
 
151
            (m_type != QVariant::Map))
 
152
        m_converted = true;
150
153
}
151
154
 
152
155
/** \brief Reduced constructor for CommandLineArg class
156
159
 *  supplied directly on the command line.
157
160
 */
158
161
CommandLineArg::CommandLineArg(QString name, QVariant::Type type, QVariant def)
159
 
  : ReferenceCounter(), m_given(false), m_name(name), m_group(""),
160
 
    m_deprecated(""), m_type(type), m_default(def)
 
162
  : ReferenceCounter(), m_given(false), m_converted(false), m_name(name),
 
163
    m_group(""), m_deprecated(""), m_type(type), m_default(def)
161
164
{
 
165
    if ((m_type != QVariant::String) && (m_type != QVariant::StringList) &&
 
166
            (m_type != QVariant::Map))
 
167
        m_converted = true;
162
168
}
163
169
 
164
170
/** \brief Dummy constructor for CommandLineArg class
169
175
 *  name prior to parsing inputs.
170
176
 */
171
177
CommandLineArg::CommandLineArg(QString name) :
172
 
    ReferenceCounter(), m_given(false), m_name(name), m_deprecated(""),
173
 
    m_type(QVariant::Invalid)
 
178
    ReferenceCounter(), m_given(false), m_converted(false), m_name(name),
 
179
    m_deprecated(""), m_type(QVariant::Invalid)
174
180
{
175
181
}
176
182
 
406
412
 
407
413
/** \brief Set option as provided on command line with value
408
414
 */
409
 
bool CommandLineArg::Set(QString opt, QString val)
 
415
bool CommandLineArg::Set(QString opt, QByteArray val)
410
416
{
411
 
    QStringList slist;
 
417
    QVariantList vlist;
 
418
    QList<QByteArray> blist;
412
419
    QVariantMap vmap;
413
 
 
414
420
    m_usedKeyword = opt;
415
421
 
416
422
    switch (m_type)
441
447
        break;
442
448
 
443
449
      case QVariant::DateTime:
444
 
        m_stored = QVariant(myth_dt_from_string(val));
 
450
        m_stored = QVariant(myth_dt_from_string(QString(val)));
445
451
        break;
446
452
 
447
453
      case QVariant::StringList:
448
454
        if (!m_stored.isNull())
449
 
            slist = m_stored.toStringList();
450
 
        slist << val;
451
 
        m_stored = QVariant(slist);
 
455
            vlist = m_stored.toList();
 
456
        vlist << val;
 
457
        m_stored = QVariant(vlist);
452
458
        break;
453
459
 
454
460
      case QVariant::Map:
459
465
            return false;
460
466
        }
461
467
 
462
 
        slist = val.split('=');
 
468
        blist = val.split('=');
463
469
 
464
470
        if (!m_stored.isNull())
465
471
            vmap = m_stored.toMap();
466
 
        vmap[slist[0]] = QVariant(slist[1]);
 
472
        vmap[QString(blist[0])] = QVariant(blist[1]);
467
473
        m_stored = QVariant(vmap);
468
474
        break;
469
475
 
475
481
            return false;
476
482
        }
477
483
 
478
 
        slist = val.split('x');
479
 
        m_stored = QVariant(QSize(slist[0].toInt(), slist[1].toInt()));
 
484
        blist = val.split('x');
 
485
        m_stored = QVariant(QSize(blist[0].toInt(), blist[1].toInt()));
480
486
        break;
481
487
 
482
488
      default:
791
797
    }
792
798
}
793
799
 
 
800
/** \brief Convert stored string value from QByteArray to QString
 
801
 *
 
802
 *  This is a work around to delay string processing until after QApplication
 
803
 *  has been initialized, to allow the locale to be configured and unicode
 
804
 *  handling to work properly
 
805
 */
 
806
void CommandLineArg::Convert(void)
 
807
{
 
808
    if (!QCoreApplication::instance())
 
809
        // QApplication not available, no sense doing anything yet
 
810
        return;
 
811
 
 
812
    if (m_converted)
 
813
        // already run, abort
 
814
        return;
 
815
 
 
816
    if (!m_given)
 
817
    {
 
818
        // nothing to work on, abort
 
819
        m_converted = true;
 
820
        return;
 
821
    }
 
822
 
 
823
    if (m_type == QVariant::String)
 
824
    {
 
825
        if (m_stored.type() == QVariant::ByteArray)
 
826
        {
 
827
            m_stored = QString::fromLocal8Bit(m_stored.toByteArray());
 
828
        }
 
829
        // else
 
830
        //      not sure why this isnt a bytearray, but ignore it and
 
831
        //      set it as converted
 
832
    }
 
833
    else if (m_type == QVariant::StringList)
 
834
    {
 
835
        if (m_stored.type() == QVariant::List)
 
836
        {
 
837
            QVariantList vlist = m_stored.toList();
 
838
            QVariantList::const_iterator iter = vlist.begin();
 
839
            QStringList slist;
 
840
            for (; iter != vlist.end(); ++iter)
 
841
                slist << QString::fromLocal8Bit(iter->toByteArray());
 
842
            m_stored = QVariant(slist);
 
843
        }
 
844
    }
 
845
    else if (m_type == QVariant::Map)
 
846
    {
 
847
        QVariantMap vmap = m_stored.toMap();
 
848
        QVariantMap::iterator iter = vmap.begin();
 
849
        for (; iter != vmap.end(); ++iter)
 
850
            (*iter) = QString::fromLocal8Bit(iter->toByteArray());
 
851
    }
 
852
    else
 
853
        return;
 
854
 
 
855
    m_converted = true;
 
856
}
 
857
 
 
858
 
794
859
/** \brief Return the longest keyword for the argument
795
860
 *
796
861
 *  This is used to determine which keyword to use when listing relations to
917
982
    QSize tmpsize;
918
983
    QMap<QString, QVariant> tmpmap;
919
984
    QMap<QString, QVariant>::const_iterator it;
 
985
    QVariantList vlist;
 
986
    QVariantList::const_iterator it2;
920
987
    bool first;
921
988
 
922
989
    switch (m_type)
949
1016
        break;
950
1017
 
951
1018
      case QVariant::String:
952
 
        cerr << '"' << m_stored.toString().toLocal8Bit().constData()
 
1019
        cerr << '"' << m_stored.toByteArray().constData()
953
1020
             << '"' << endl;
954
1021
        break;
955
1022
 
956
1023
      case QVariant::StringList:
957
 
        cerr << '"' << m_stored.toStringList().join("\", \"")
958
 
                               .toLocal8Bit().constData()
959
 
             << '"' << endl;
 
1024
        vlist = m_stored.toList();
 
1025
        it2 = vlist.begin();
 
1026
        cerr << '"' << it2->toByteArray().constData() << '"';
 
1027
        ++it2;
 
1028
        for (; it2 != vlist.end(); ++it2)
 
1029
            cerr << ", \""
 
1030
                 << it2->constData()
 
1031
                 << '"';
 
1032
        cerr << endl;
960
1033
        break;
961
1034
 
962
1035
      case QVariant::Map:
973
1046
 
974
1047
            cerr << it.key().toLocal8Bit().constData()
975
1048
                 << '='
976
 
                 << (*it).toString().toLocal8Bit().constData()
 
1049
                 << it->toByteArray().constData()
977
1050
                 << endl;
978
1051
        }
979
1052
 
1193
1266
/** \brief Internal use. Pull next key/value pair from argv.
1194
1267
 */
1195
1268
int MythCommandLineParser::getOpt(int argc, const char * const * argv,
1196
 
                                    int &argpos, QString &opt, QString &val)
 
1269
                                  int &argpos, QString &opt, QByteArray &val)
1197
1270
{
1198
1271
    opt.clear();
1199
1272
    val.clear();
1202
1275
        // this shouldnt happen, return and exit
1203
1276
        return kEnd;
1204
1277
 
1205
 
    QString tmp = QString::fromLocal8Bit(argv[argpos]);
 
1278
    QByteArray tmp(argv[argpos]);
1206
1279
    if (tmp.isEmpty())
1207
1280
        // string is empty, return and loop
1208
1281
        return kEmpty;
1214
1287
        return kArg;
1215
1288
    }
1216
1289
 
1217
 
    if (tmp.startsWith("-") && tmp.size() > 1)
 
1290
    if (tmp.startsWith('-') && tmp.size() > 1)
1218
1291
    {
1219
1292
        if (tmp == "--")
1220
1293
        {
1223
1296
            return kPassthrough;
1224
1297
        }
1225
1298
 
1226
 
        if (tmp.contains("="))
 
1299
        if (tmp.contains('='))
1227
1300
        {
1228
1301
            // option contains '=', split
1229
 
            QStringList slist = tmp.split("=");
 
1302
            QList<QByteArray> blist = tmp.split('=');
1230
1303
 
1231
 
            if (slist.size() != 2)
 
1304
            if (blist.size() != 2)
1232
1305
            {
1233
1306
                // more than one '=' in option, this is not handled
1234
 
                opt = tmp;
 
1307
                opt = QString(tmp);
1235
1308
                return kInvalid;
1236
1309
            }
1237
1310
 
1238
 
            opt = slist[0];
1239
 
            val = slist[1];
 
1311
            opt = QString(blist[0]);
 
1312
            val = blist[1];
1240
1313
            return kOptVal;
1241
1314
        }
1242
1315
 
1243
 
        opt = tmp;
 
1316
        opt = QString(tmp);
1244
1317
 
1245
1318
        if (argpos+1 >= argc)
1246
1319
            // end of input, option only
1247
1320
            return kOptOnly;
1248
1321
 
1249
 
        tmp = QString::fromLocal8Bit(argv[++argpos]);
 
1322
        tmp = QByteArray(argv[++argpos]);
1250
1323
        if (tmp.isEmpty())
1251
1324
            // empty string, option only
1252
1325
            return kOptOnly;
1279
1352
bool MythCommandLineParser::Parse(int argc, const char * const * argv)
1280
1353
{
1281
1354
    int res;
1282
 
    QString opt, val;
 
1355
    QString opt;
 
1356
    QByteArray val;
1283
1357
    CommandLineArg *argdef;
1284
1358
 
1285
1359
    // loop through command line arguments until all are spent
1293
1367
        if (m_verbose)
1294
1368
            cerr << "res: " << NamedOptType(res) << endl
1295
1369
                 << "opt:  " << opt.toLocal8Bit().constData() << endl
1296
 
                 << "val:  " << val.toLocal8Bit().constData() << endl << endl;
 
1370
                 << "val:  " << val.constData() << endl << endl;
1297
1371
 
1298
1372
        // '--' found on command line, enable passthrough mode
1299
1373
        if (res == kPassthrough && !m_namedArgs.contains("_passthrough"))
1332
1406
            if (!m_namedArgs.contains("_args"))
1333
1407
            {
1334
1408
                cerr << "Received '"
1335
 
                     << val.toAscii().constData()
 
1409
                     << val.constData()
1336
1410
                     << "' but unassociated arguments have not been enabled"
1337
1411
                     << endl;
1338
1412
                return false;        
1366
1440
            {
1367
1441
                // arbitrary allowed, specify general collection pool
1368
1442
                argdef = m_namedArgs["_extra"];
1369
 
                QString tmp = QString("%1=%2").arg(opt).arg(val);
 
1443
                QByteArray tmp = opt.toLocal8Bit();
 
1444
                tmp += '=';
 
1445
                tmp += val;
1370
1446
                val = tmp;
1371
1447
                res = kOptVal;
1372
1448
            }
1404
1480
        else if (res == kOptVal)
1405
1481
        {
1406
1482
            if (!argdef->Set(opt, val))
1407
 
                return false;
 
1483
            {
 
1484
                // try testing keyword with no value
 
1485
                if (!argdef->Set(opt))
 
1486
                    return false;
 
1487
                // drop back an iteration so the unused value will get
 
1488
                // processed a second time as a keyword-less argument
 
1489
                --argpos;
 
1490
            }
1408
1491
        }
1409
1492
        else
1410
1493
            return false; // this should not occur
1883
1966
 
1884
1967
    if (arg->m_given)
1885
1968
    {
 
1969
        if (!arg->m_converted)
 
1970
            arg->Convert();
 
1971
 
1886
1972
        if (arg->m_stored.canConvert(QVariant::String))
1887
1973
            val = arg->m_stored.toString();
1888
1974
    }
1909
1995
    CommandLineArg *arg = m_namedArgs[key];
1910
1996
 
1911
1997
    if (arg->m_given)
 
1998
    {
 
1999
        if (!arg->m_converted)
 
2000
            arg->Convert();
 
2001
 
1912
2002
        varval = arg->m_stored;
 
2003
    }
1913
2004
    else
1914
2005
        varval = arg->m_default;
1915
2006
 
1935
2026
 
1936
2027
    if (arg->m_given)
1937
2028
    {
 
2029
        if (!arg->m_converted)
 
2030
            arg->Convert();
 
2031
 
1938
2032
        if (arg->m_stored.canConvert(QVariant::Map))
1939
2033
            tmp = arg->m_stored.toMap();
1940
2034
    }