Index: libs/libmythtv/channeleditor.cpp
===================================================================
--- libs/libmythtv/channeleditor.cpp	(revision 13313)
+++ libs/libmythtv/channeleditor.cpp	(working copy)
@@ -19,6 +19,7 @@
 #include "sourceutil.h"
 
 #include "scanwizard.h"
+#include "importicons.h"
 
 ChannelWizard::ChannelWizard(int id, int default_sourceid)
              : ConfigurationWizard() {
@@ -110,12 +111,13 @@
         return 0;
 }
 
-void ChannelListSetting::fillSelections(void) 
+int ChannelListSetting::fillSelections(void) 
 {
     QString currentValue = getValue();
     clearSelections();
     addSelection(QObject::tr("(New Channel)"));
     bool fAllSources = true;
+    int nCount = 0;
 
     QString querystr = "SELECT channel.name,channum,chanid ";
 
@@ -184,8 +186,10 @@
                 name += " (" + sourceid  + ")";
 
             addSelection(name, chanid, (chanid == currentValue) ? true : false);
+            nCount++;
         }
     }
+    return nCount;
 }
 
 class SourceSetting : public ComboBoxSetting, public Storage
@@ -268,6 +272,10 @@
     buttonScan->setHelpText(QObject::tr("Starts the channel scanner."));
     buttonScan->setEnabled(SourceUtil::IsAnySourceScanable());
 
+    buttonImportIcon = new TransButtonSetting();
+    buttonImportIcon->setLabel(QObject::tr("Icon Import"));
+    buttonImportIcon->setHelpText(QObject::tr("Starts the icon importer"));
+
     buttonTransportEditor = new TransButtonSetting();
     buttonTransportEditor->setLabel(QObject::tr("Transport Editor"));
     buttonTransportEditor->setHelpText(
@@ -279,6 +287,7 @@
     HorizontalConfigurationGroup *h = 
         new HorizontalConfigurationGroup(false, false);
     h->addChild(buttonScan);
+    h->addChild(buttonImportIcon);
     h->addChild(buttonTransportEditor);
     addChild(h);
 
@@ -294,6 +303,8 @@
             this, SLOT(menu(int)));
     connect(buttonScan, SIGNAL(pressed()),
             this, SLOT(scan()));
+    connect(buttonImportIcon,  SIGNAL(pressed()),
+            this, SLOT(channelIconImport()));
     connect(buttonTransportEditor, SIGNAL(pressed()),
             this, SLOT(transportEditor()));
     connect(del,  SIGNAL(pressed()),
@@ -355,7 +366,7 @@
     if (!query.exec())
         MythContext::DBError("ChannelEditor Delete Channels", query);
 
-    list->fillSelections();
+    buttonImportIcon->setEnabled(list->fillSelections()==0 ? false:true);
 }
 
 MythDialog* ChannelEditor::dialogWidget(MythMainWindow* parent,
@@ -379,7 +390,7 @@
     ChannelWizard cw(id, source->getValue().toUInt());
     cw.exec();
 
-    list->fillSelections();
+    buttonImportIcon->setEnabled(list->fillSelections()==0 ? false:true);
     list->setFocus();
 }
 
@@ -406,7 +417,7 @@
         if (!query.exec() || !query.isActive())
             MythContext::DBError("ChannelEditor Delete Channel", query);
 
-        list->fillSelections();
+        buttonImportIcon->setEnabled(list->fillSelections()==0 ? false:true);
     }
 }
 
@@ -441,7 +452,7 @@
     scanwizard->exec(false, true);
     scanwizard->deleteLater();
 
-    list->fillSelections();
+    buttonImportIcon->setEnabled(list->fillSelections()==0 ? false:true);
     list->setFocus();
 #else
     VERBOSE(VB_IMPORTANT,  "You must compile the backend "
@@ -457,6 +468,39 @@
     editor->exec();
     editor->deleteLater();
 
-    list->fillSelections();
+    buttonImportIcon->setEnabled(list->fillSelections()==0 ? false:true);
     list->setFocus();
 }
+
+void ChannelEditor::channelIconImport(void)
+{
+    int val = MythPopupBox::show2ButtonPopup(gContext->GetMainWindow(),
+                                             "",
+                                             tr("Channel Icon Import"),
+                                             tr("Import all icons.."),
+                                             tr("Rescan for missing icons.."),
+                                             0);
+
+    if (val == 0)
+        emit iconImportFull();
+    else if (val == 1)
+        emit iconImportRescan();
+    else
+        list->setFocus();
+}
+
+void ChannelEditor::iconImportFull(void)
+{
+    ImportIconsWizard box(false);
+    if (!box.initialise())
+       return;
+    box.exec();
+}
+
+void ChannelEditor::iconImportRescan(void)
+{
+    ImportIconsWizard box(true);
+    if (!box.initialise())
+       return;
+    box.exec();
+}
Index: libs/libmythtv/libmythtv.pro
===================================================================
--- libs/libmythtv/libmythtv.pro	(revision 13313)
+++ libs/libmythtv/libmythtv.pro	(working copy)
@@ -148,6 +148,7 @@
 HEADERS += playgroup.h              progdetails.h
 HEADERS += channeleditor.h          channelsettings.h
 HEADERS += previewgenerator.h       transporteditor.h
+HEADERS += importicons.h
 
 SOURCES += programinfo.cpp          proglist.cpp
 SOURCES += storagegroup.cpp
@@ -170,6 +171,7 @@
 SOURCES += progdetails.cpp
 SOURCES += channeleditor.cpp        channelsettings.cpp
 SOURCES += previewgenerator.cpp     transporteditor.cpp
+SOURCES += importicons.cpp
 
 # DiSEqC
 HEADERS += diseqc.h                 diseqcsettings.h
Index: libs/libmythtv/importicons.h
===================================================================
--- libs/libmythtv/importicons.h	(revision 0)
+++ libs/libmythtv/importicons.h	(revision 0)
@@ -0,0 +1,189 @@
+/* -*- Mode: c++ -*-
+ * vim: set expandtab tabstop=4 shiftwidth=4:
+ *
+ * Original Project
+ *      MythTV      http://www.mythtv.org
+ *
+ * Author(s):
+ *      John Pullan  
+ *
+ * Description:
+ */
+
+#ifndef _IMPORTICONS_H
+#define _IMPORTICONS_H
+
+#include <qsqldatabase.h>
+#include <qurl.h>
+#include "settings.h"
+
+/** \class ImportIcons
+ *  \brief class which attempts to import icons for channels
+ *
+ *  This is a set of classes and structures which attempts to download
+ *  the icon files for a particular TV channel.
+ */
+class ImportIcons : public VerticalConfigurationGroup
+{
+    Q_OBJECT
+protected:
+    struct CSVEntry                  //! describes the TV channel name
+    {
+        QString strChanId;           //!< local channel id
+        QString strName;             //!< channel name
+        QString strXmlTvId;          //!< the xmltvid 
+        QString strCallsign;         //!< callsign
+        QString strTransportId;      //!< transport id
+        QString strAtscMajorChan;    //!< ATSC major number
+        QString strAtscMinorChan;    //!< ATSC minor number
+        QString strNetworkId;        //!< network id
+        QString strServiceId;        //!< service id
+        QString strIconCSV;          //!< icon name (csv form) 
+        QString strNameCSV;          //!< name (csv form)
+    };  
+    //! List of CSV entries
+    typedef QValueList<CSVEntry> ListEntries;     
+    //! iterator over list of CSV entries
+    typedef QValueListIterator<CSVEntry> ListEntriesIter; 
+
+    ListEntries m_listEntries;       //!< list of TV channels to search for
+    ListEntriesIter m_iter;          //!< the current iterator
+
+    struct SearchEntry               //! search entry results
+    {
+        QString strID;               //!< the remote channel id 
+        QString strName;             //!< the remote name
+        QString strLogo;             //!< the actual logo
+    };
+    //! List of SearchEntry entries
+    typedef QValueList<SearchEntry> ListSearchEntries;
+    //! iterator over list of SearchEntry entries
+    typedef QValueListIterator<SearchEntry> ListSearchEntriesIter;
+
+    ListSearchEntries m_listSearch;  //!< the list of SearchEntry
+    QString m_strMatches;            //!< the string for the submit() call
+
+    static const QString url;        //!< the default url
+    QString m_strChannelDir;         //!< the location of the channel icon dir
+
+    bool m_fRefresh;                 //!< are we doing a refresh or not
+    int m_nMaxCount;                 //!< the maximum number of TV channels
+    int m_nCount;                    //!< the current search point (0..m_nMaxCount)
+
+    /*! \brief changes a string into csv format 
+     * \param str the string to change
+     * \return the actual string
+     */ 
+    QString escape_csv(const QString& str); 
+
+    /*! \brief extracts the csv values out of a string
+     * \param str the string to work on
+     * \return the actual QStringList
+     */ 
+    QStringList extract_csv(const QString& strLine);
+
+    /*! \brief use the equivalent of wget to fetch the POST command
+     * \param url the url to send this to
+     * \param strParam the string to send
+     * \return the actual string
+     */ 
+    QString wget(QUrl& url,const QString& strParam);
+ 
+    TransLineEditSetting *m_editName;    //!< name field for the icon 
+    TransListBoxSetting *m_listIcons;    //!< list of potential icons
+    TransLineEditSetting *m_editManual;  //!< manual edit field
+    TransButtonSetting *m_buttonManual;  //!< manual button field
+    TransButtonSetting *m_buttonSkip;    //!< button skip
+
+    /*! \brief detemines if you can actually reach the net
+     * \return true/false
+     */ 
+    bool ping();                       
+
+    /*! \brief determines if a particular icon is blocked
+     * \param str the string to work on
+     * \return true/false
+     */ 
+    bool isBlocked(const QString& strParam);
+
+    /*! \brief looks up the string to determine the caller/xmltvid
+     * \param str the string to work on
+     * \return true/false
+     */ 
+    bool lookup(const QString& strParam);
+
+    /*! \brief search the remote db for icons etc
+     * \param str the string to work on
+     * \return true/false
+     */ 
+    bool search(const QString& strParam);
+
+    /*! \brief submit the icon information back to the remote db
+     * \param str the string to work on
+     * \return true/false
+     */ 
+    bool submit(const QString& strParam);
+
+    /*! \brief retrieve the actual logo for the TV channel
+     * \param str the string to work on
+     * \return true/false
+     */ 
+    bool findmissing(const QString& strParam);
+
+    /*! \brief checks and attempts to download the logo file to the appropriate
+     *   place
+     * \param str the string of the downloaded url
+     * \return true/false
+     */ 
+    bool checkAndDownload(const QString& str);
+
+    /*! \brief attempt the inital load of the TV channel information
+     * \return the number of TV channels
+     */ 
+    unsigned initialLoad();
+
+    /*! \brief attempts to move the itaration on one/more than one
+     * \return true if we can go again or false if we can not
+     */ 
+    bool doLoad();
+
+public:
+    ImportIcons(bool fRefresh);    //!< constructs an icon import page
+
+    bool initialise();             //!< returns true if the net is pingable etc.
+
+protected slots:
+    void enableControls();         //!< enable/disable the controls
+    void manualSearch();           //!< process the manual search
+    void menuSelection(int nIndex);//!< process the icon selection
+    void skip();                   //!< skip this icon
+};
+
+/** \class ImportIconsWizard
+ *  \brief class which constructs an ImportIconsWizard, with an appropriate
+ *         ImportIcons child in it.
+ */
+class ImportIconsWizard : public QObject, public ConfigurationWizard
+{
+    Q_OBJECT
+protected:
+    ImportIcons *m_ImportIcons;      //!< pointer to the ImportIcons class
+    //! \brief result to be used in exec() and finishButtonPressed()
+    bool m_fResult;               
+
+public:
+    ImportIconsWizard(bool fRefresh); //!< constructs an ImportIconWizard
+
+    /*! \brief go through each of the sheets to determine if anything fails
+     * return true/false
+     */
+    bool initialise();
+
+    virtual int exec();               //!< executes the wizard
+    virtual MythDialog *dialogWidget(MythMainWindow *parent, 
+                         const char *widgetName); //!< returns the MythDialog
+protected slots:
+    void finishButtonPressed();       //!< was the finish button pressed
+};
+
+#endif // _IMPORTICONS_H
Index: libs/libmythtv/channeleditor.h
===================================================================
--- libs/libmythtv/channeleditor.h	(revision 13313)
+++ libs/libmythtv/channeleditor.h	(working copy)
@@ -22,14 +22,18 @@
     void edit();
     void edit(int);
     void scan(void);
-    void transportEditor();
-    void deleteChannels();
+    void transportEditor(void);
+    void channelIconImport(void);
+    void deleteChannels(void);
+    void iconImportFull(void);
+    void iconImportRescan(void);
 
 private:
     int                 id;
     SourceSetting      *source;
     ChannelListSetting *list;
     TransButtonSetting *buttonScan;
+    TransButtonSetting *buttonImportIcon;
     TransButtonSetting *buttonTransportEditor;
 };
 
@@ -68,7 +72,7 @@
     bool getHideMode() { return currentHideMode; };
 
 public slots:
-    void fillSelections(void);
+    int fillSelections(void);
     void setSortMode(const QString& sort) {
         if (currentSortMode != sort) {
             currentSortMode = sort;
Index: libs/libmythtv/importicons.cpp
===================================================================
--- libs/libmythtv/importicons.cpp	(revision 0)
+++ libs/libmythtv/importicons.cpp	(revision 0)
@@ -0,0 +1,594 @@
+extern "C"
+{
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+};
+
+#include <httpcomms.h>
+#include "mythcontext.h"
+#include "mythdbcon.h"
+#include "mythwidgets.h"
+
+#include <qapplication.h>
+#include <qregexp.h>
+#include <qlayout.h>
+#include <qdialog.h>
+#include <qcursor.h>
+#include <qbuffer.h>
+#include <qfileinfo.h>
+
+#include <mythwidgets.h>
+#include <mythdialogs.h>
+#include <mythwizard.h>
+
+#include "importicons.h"
+
+ImportIconsWizard::ImportIconsWizard(bool fRefresh)
+{
+    m_fResult = false;
+    addChild(m_ImportIcons = new ImportIcons(fRefresh));
+}
+
+bool ImportIconsWizard::initialise()
+{
+    if (m_ImportIcons->initialise())
+        return true; 
+    else
+        return false; 
+}
+
+MythDialog *ImportIconsWizard::dialogWidget(MythMainWindow *parent,
+                                     const char *widgetName)
+{
+    MythWizard *ret = (MythWizard*)ConfigurationWizard::dialogWidget(parent,widgetName);
+    connect(ret->finishButton(), SIGNAL(pressed()), this, SLOT(finishButtonPressed()));
+    return (MythDialog*)ret;
+}
+
+int ImportIconsWizard::exec()
+{
+    while ((ConfigurationDialog::exec() == QDialog::Accepted) && !m_fResult) {}
+    return QDialog::Rejected;
+}
+
+void ImportIconsWizard::finishButtonPressed()
+{
+    m_fResult = true;
+}
+
+const QString ImportIcons::url="http://services.mythtv.org/channel-icon/";
+
+ImportIcons::ImportIcons(bool fRefresh) 
+{
+    m_fRefresh = fRefresh;
+
+    addChild(m_editName = new TransLineEditSetting(false));
+    m_editName->setLabel(QObject::tr("Name"));
+    m_editName->setHelpText(QObject::tr("Name of the icon file"));
+
+    addChild(m_listIcons = new TransListBoxSetting());
+    m_listIcons->setHelpText(QObject::tr("List of possible icon files"));
+
+    m_editManual = new TransLineEditSetting();
+    //m_editManual->setLabel(QObject::tr("Enter text"));
+    m_editManual->setHelpText(QObject::tr("Enter text here for the manual search"));
+
+    m_buttonManual = new TransButtonSetting();
+    m_buttonManual->setLabel(QObject::tr("&Search"));
+    m_buttonManual->setHelpText(QObject::tr("Manually search for the text"));
+
+    m_buttonSkip = new TransButtonSetting();
+    m_buttonSkip->setLabel(QObject::tr("S&kip"));
+    m_buttonSkip->setHelpText(QObject::tr("Skip this icon"));
+
+    HorizontalConfigurationGroup *hrz1 =
+        new HorizontalConfigurationGroup(false, false, true, true);
+
+    hrz1->addChild(m_editManual);
+    hrz1->addChild(m_buttonManual);
+    hrz1->addChild(m_buttonSkip);
+    addChild(hrz1);
+
+    connect(m_editManual, SIGNAL(valueChanged( const QString&)),
+            this, SLOT(  enableControls()));
+    connect(m_buttonManual, SIGNAL(pressed()), this, SLOT(manualSearch()));
+    connect(m_buttonSkip, SIGNAL(pressed()), this, SLOT(skip()));
+    connect(m_listIcons,SIGNAL(accepted(int)),this,
+             SLOT(menuSelection(int)));
+
+    enableControls();
+}
+
+bool ImportIcons::initialise()
+{
+    m_strChannelDir =  MythContext::GetConfDir()+ "/channels";
+    mkdir(MythContext::GetConfDir(),0776);
+    mkdir(m_strChannelDir,0776);
+    m_strChannelDir+="/";
+
+    if (!ping())
+    {
+        MythPopupBox::showOkPopup(gContext->GetMainWindow(),
+                                  tr("Bad Host"),
+                                  tr("Failed to connect to the remote server"));
+        return false;
+    }
+
+    if (initialLoad() > 0)
+    {
+        doLoad();
+        return true;
+    }
+    else
+        return false;
+}
+
+void ImportIcons::enableControls()
+{
+   if (m_editManual->getValue().length())
+       m_buttonManual->setEnabled(true);
+   else
+       m_buttonManual->setEnabled(false);
+   if (m_nCount < m_nMaxCount)
+   {
+       m_buttonSkip->setEnabled(true);
+       m_editName->setEnabled(true);
+       m_listIcons->setEnabled(true);
+       m_editManual->setEnabled(true);
+   }
+   else
+   {
+       m_buttonSkip->setEnabled(false);
+       m_editName->setEnabled(false);
+       m_listIcons->setEnabled(false);
+       m_editManual->setEnabled(false);
+       m_buttonManual->setEnabled(false);
+   }
+}
+
+void ImportIcons::manualSearch()
+{
+    QString str = m_editManual->getValue();
+    search(escape_csv(str));    
+}
+
+void ImportIcons::skip()
+{
+    doLoad();
+    enableControls();
+}
+
+void ImportIcons::menuSelection(int nIndex)
+{
+    SearchEntry entry = *(m_listSearch.at(nIndex));
+    if (!isBlocked((*m_iter).strIconCSV) && 
+         checkAndDownload(entry.strLogo))
+    {
+        CSVEntry entry2 = (*m_iter);
+        m_strMatches += QString("%1,%2,%3,%4,%5,%6,%7,%8,%9\n").
+                              arg(escape_csv(entry.strID)).
+                              arg(escape_csv(entry2.strName)).
+                              arg(escape_csv(entry2.strXmlTvId)).
+                              arg(escape_csv(entry2.strCallsign)).
+                              arg(escape_csv(entry2.strTransportId)).
+                              arg(escape_csv(entry2.strAtscMajorChan)).
+                              arg(escape_csv(entry2.strAtscMinorChan)).
+                              arg(escape_csv(entry2.strNetworkId)).
+                              arg(escape_csv(entry2.strServiceId));
+        m_nCount++;
+        m_iter++;
+        doLoad();
+        enableControls();
+    }
+    else
+        MythPopupBox::showOkPopup(gContext->GetMainWindow(),
+                            QObject::tr("Error downloading"),
+                            QObject::tr("Failed to download the icon file"));        
+    
+}
+
+unsigned ImportIcons::initialLoad()
+{
+    MSqlQuery query(MSqlQuery::InitCon());
+    query.prepare("SELECT chanid,name,xmltvid,callsign,"
+                  "dtv_multiplex.transportid, "
+                  "atsc_major_chan,atsc_minor_chan,dtv_multiplex.networkid,"
+                  "channel.serviceid, "
+                  "channel.mplexid, dtv_multiplex.mplexid,"
+                  "channel.icon, channel.visible FROM "
+                  "channel, dtv_multiplex WHERE "
+                  "channel.visible && "
+                  "channel.mplexid=dtv_multiplex.mplexid ORDER BY name");
+       
+    m_listEntries.clear();           
+    m_nCount=0;
+    m_nMaxCount=0;
+    if (query.exec() && query.isActive() && query.size() > 0)
+    {
+        while(query.next()) 
+        {
+            CSVEntry entry;
+
+            if (m_fRefresh)
+            {
+                QFileInfo file(query.value(11).toString());
+                if (file.exists())
+                    continue;
+            }
+           
+            entry.strChanId=query.value(0).toString();
+            entry.strName=query.value(1).toString();
+            entry.strXmlTvId=query.value(2).toString();
+            entry.strCallsign=query.value(3).toString(); 
+            entry.strTransportId=query.value(4).toString();
+            entry.strAtscMajorChan=query.value(5).toString();
+            entry.strAtscMinorChan=query.value(6).toString();
+            entry.strNetworkId=query.value(7).toString();
+            entry.strServiceId=query.value(8).toString();
+            entry.strIconCSV= QString("%1,%2,%3,%4,%5,%6,%7,%8,%9\n").
+                              arg(escape_csv(entry.strChanId)).
+                              arg(escape_csv(entry.strName)).
+                              arg(escape_csv(entry.strXmlTvId)).
+                              arg(escape_csv(entry.strCallsign)).
+                              arg(escape_csv(entry.strTransportId)).
+                              arg(escape_csv(entry.strAtscMajorChan)).
+                              arg(escape_csv(entry.strAtscMinorChan)).
+                              arg(escape_csv(entry.strNetworkId)).
+                              arg(escape_csv(entry.strServiceId));
+            entry.strNameCSV=escape_csv(entry.strName);
+//            VERBOSE(VB_IMPORTANT,QString("chanid %1").arg(entry.strIconCSV));
+
+            m_listEntries.append(entry);
+            m_nMaxCount++;
+        }
+    }
+    m_iter = m_listEntries.begin();
+    return m_nMaxCount; 
+}
+
+bool ImportIcons::doLoad()
+{
+    bool fFinish = false;
+    m_listIcons->clearSelections();
+    m_editName->setValue("");
+    while (!fFinish && (m_iter != m_listEntries.end()))
+    {
+        if (findmissing((*m_iter).strIconCSV))
+        {
+            m_nCount++;
+            m_iter++;    
+        }
+        else
+        { 
+            m_editName->setValue((*m_iter).strName);
+            search((*m_iter).strNameCSV);
+            fFinish = true;
+        }
+    }
+    if (m_iter==m_listEntries.end())
+    {
+        if (!m_strMatches.isEmpty())
+        {
+            int nVal = MythPopupBox::showOkCancelPopup(
+                            gContext->GetMainWindow(),
+                            QObject::tr("Submit information"),
+                            QObject::tr("You now have the opportunity to "
+                                        "transmit your choices  back to "
+                                        "mythtv.org so that others can "
+                                        "benefit from your selections."),
+                          true);        
+             if (nVal == 1)
+                 submit(m_strMatches);
+        }
+        return false;
+    }
+    else
+        return true;
+}
+
+QString ImportIcons::escape_csv(const QString& str)
+{
+    QRegExp rxDblForEscape("\"");
+    QString str2 = str;
+    str2.replace(rxDblForEscape,"\\\"");
+    return "\""+str2+"\"";
+}
+
+QStringList ImportIcons::extract_csv(const QString& strLine)
+{
+    QStringList ret;
+    //Clean up the line and split out the fields
+    QString str = strLine;
+
+    unsigned int pos = 0;
+    bool fFinish = false;
+    while(!fFinish)
+    {
+        str=str.stripWhiteSpace();
+        while(!fFinish)
+        {
+            QString strLeft;
+            switch (str.at(pos).unicode())
+            {
+            case '\\':
+                if (pos>=1)
+                    str.left(pos-1)+str.mid(pos+1);
+                else
+                    str=str.mid(pos+1);
+                pos+=2;
+                if (pos > str.length())
+                {
+                    strLeft = str.left(pos); 
+                    if (strLeft.startsWith("\"") && strLeft.endsWith("\""))
+                        strLeft=strLeft.mid(1,strLeft.length()-2);
+                    ret.append(strLeft);
+                    fFinish = true;
+                }
+                break;
+            case ',':
+                strLeft = str.left(pos); 
+                if (strLeft.startsWith("\"") && strLeft.endsWith("\""))
+                    strLeft=strLeft.mid(1,strLeft.length()-2);
+                ret.append(strLeft);
+                if ((pos+1) > str.length())
+                   fFinish = true;
+                str=str.mid(pos+1);
+                pos=0;
+                break;
+            default:
+                pos++;
+                if (pos > str.length())
+                {
+                    strLeft = str.left(pos); 
+                    if (strLeft.startsWith("\"") && strLeft.endsWith("\""))
+                        strLeft=strLeft.mid(1,strLeft.length()-2);
+                    ret.append(strLeft);
+                    fFinish = true;
+                }
+            }
+        }
+    }
+    return ret;
+}
+
+
+QString ImportIcons::wget(QUrl& url,const QString& strParam )
+{
+    QByteArray raw;
+    QTextStream rawStream(raw,IO_WriteOnly);
+    rawStream << strParam;
+
+    QBuffer data(raw);
+    QHttpRequestHeader header;
+
+    header.setContentType(QString("application/x-www-form-urlencoded"));
+    header.setContentLength(raw.size());
+
+    header.setValue("User-Agent", "MythTV Channel Icon lookup bot");
+
+    QString str = HttpComms::postHttp(url,&header,&data);
+
+    return str;
+}
+
+bool ImportIcons::checkAndDownload(const QString& str)
+{
+    int iIndex = str.findRev('/');
+    QString str2;
+    if (iIndex < 0)
+        str2=str;
+    else
+        str2=str.mid(iIndex+1);
+
+    QString str3 = str;
+    QFileInfo file(m_strChannelDir+str2);
+
+    bool fRet;
+    if (!file.exists())
+        fRet = HttpComms::getHttpFile(m_strChannelDir+str2,str3);    
+    else
+        fRet = true;
+
+    if (fRet)
+    {
+        MSqlQuery query(MSqlQuery::InitCon());
+        QString  qstr = "UPDATE channel SET icon = :ICON "
+                        "WHERE chanid = :CHANID";
+
+        query.prepare(qstr);
+        query.bindValue(":ICON", m_strChannelDir+str2);
+        query.bindValue(":CHANID", (*m_iter).strChanId);
+
+        if (!query.exec())
+        {
+            MythContext::DBError("Error inserting channel icon", query);
+            return false;
+        }
+ 
+    }
+    return fRet;
+}
+
+bool ImportIcons::ping()
+{
+    QString ping= ImportIcons::url+"/ping";
+    QString str = HttpComms::getHttp(ping);
+    QRegExp pattern("^\\d+\\n$");
+
+    if (str.isEmpty() || (pattern.search(str) >= 0))
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Working ping"));
+        return true;
+    }
+    else
+    {
+        VERBOSE(VB_IMPORTANT, QString("Error from  : %1").arg(str));
+        return true;
+    }
+}
+
+bool ImportIcons::isBlocked(const QString& strParam)
+{
+    QString strParam1 = strParam;
+    QUrl::encode(strParam1);
+    QUrl url(ImportIcons::url+"/checkblock");
+    QString str = wget(url,"csv="+strParam1);
+    if (str.startsWith("Error",false))
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Error from isBlocked : %1").arg(str));
+        return true;
+    }
+    else if (str.isEmpty() || str.startsWith("\r\n"))
+        return false;
+    else
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Working isBlocked"));
+        int nVal = MythPopupBox::showOkCancelPopup(gContext->GetMainWindow(),
+                            QObject::tr("Icon is blocked"),
+                            QObject::tr("This combination of channel and icon "
+                                        "has been blocked by the MythTV "
+                                        "admins. The most common reason for "
+                                        "this is that there is a better match "
+                                        "available.\n "
+                                        "Are you still sure that you want to "
+                                        "use this icon?"),
+                          true);        
+        if (nVal == 0)
+            return false;
+        else
+            return true;
+    }
+}
+
+
+bool ImportIcons::lookup(const QString& strParam)
+{
+    HttpComms http;
+    QString strParam1 = "callsign="+strParam;
+    QUrl::encode(strParam1);
+    QUrl url(ImportIcons::url+"/lookup");
+
+    QString str = wget(url,strParam1);
+    if (str.isEmpty() || str.startsWith("Error",false))
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Error from lookup : %1").arg(str));
+        return true;
+    }
+    else
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Working lookup : %1").arg(str));
+        return false;
+    }
+}
+
+bool ImportIcons::search(const QString& strParam)
+{
+    HttpComms http;
+    QString strParam1 = strParam;
+    QUrl::encode(strParam1);
+    QUrl url(ImportIcons::url+"/search");
+
+    m_listSearch.clear();
+    m_listIcons->clearSelections();
+    QString str = wget(url,"s="+strParam1);
+    if (str.isEmpty() || str.startsWith("#") || str.startsWith("Error",false))
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Error from search : %1").arg(str));
+        return false;
+    }
+    else
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Working search : %1").arg(str));
+        QStringList strSplit=QStringList::split("\n",str);
+        for (QStringList::iterator begin=strSplit.begin();
+             begin!=strSplit.end();begin++)
+        {
+            if (*begin != "#" )
+            {
+                QStringList ret = extract_csv(*begin); 
+//                VERBOSE(VB_IMPORTANT, QString(" search : %1 %2 %3").arg(ret[0]).arg(ret[1]).arg(ret[2]));
+                SearchEntry entry;
+                entry.strID=ret[0];
+                entry.strName=ret[1];
+                entry.strLogo=ret[2];
+                m_listSearch.append(entry);
+                m_listIcons->addSelection(entry.strName);
+            }
+        }
+        return true;
+    }
+}
+
+bool ImportIcons::findmissing(const QString& strParam)
+{
+    HttpComms http;
+    QString strParam1 = strParam;
+    QUrl::encode(strParam1);
+    QUrl url(ImportIcons::url+"/findmissing");
+
+    QString str = wget(url,"csv="+strParam1);
+    if (str.isEmpty() || str.startsWith("#") || str.startsWith("Error",false))
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Error from findmissing : %1").arg(str));
+        return false;
+    }
+    else
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Working findmissing : %1").arg(str));
+        QStringList strSplit=QStringList::split("\n",str);
+        for (QStringList::iterator begin=strSplit.begin();
+             begin!=strSplit.end();begin++)
+        {
+            if (*begin != "#" )
+            {
+                QStringList ret = extract_csv(*begin); 
+//                VERBOSE(VB_IMPORTANT, QString(" findmissing : %1 %2 %3 %4 %5").arg(ret[0]).arg(ret[1]).arg(ret[2]).arg(ret[3]).arg(ret[4]));
+                checkAndDownload(ret[4]);
+            }
+        }
+        return true;
+    }
+}
+
+bool ImportIcons::submit(const QString& strParam)
+{
+    HttpComms http;
+    QString strParam1 = strParam;
+    QUrl::encode(strParam1);
+    QUrl url(ImportIcons::url+"/submit");
+
+    QString str = wget(url,"csv="+strParam1);
+    if (str.isEmpty() || str.startsWith("#") || str.startsWith("Error",false))
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Error from submit : %1").arg(str));
+        return false;
+    }
+    else
+    {
+//        VERBOSE(VB_IMPORTANT, QString("Working submit : %1").arg(str));
+        QStringList strSplit=QStringList::split("\n",str);
+        unsigned atsc =0, dvb =0, callsign =0, tv =0, xmltvid=0;
+        for (QStringList::iterator begin=strSplit.begin();
+             begin!=strSplit.end();begin++)
+        {
+            if (*begin != "#" )
+            {
+                QStringList strSplit2=QStringList::split(":",*begin);
+                QString s=strSplit2[0].stripWhiteSpace();
+                if (s=="a")
+                     atsc=strSplit2[1].toUInt();
+                else if (s=="c")
+                     callsign=strSplit2[1].toUInt();
+                else if (s=="d")
+                     dvb=strSplit2[1].toUInt();
+                else if (s=="t")
+                     tv=strSplit2[1].toUInt();
+                else if (s=="x")
+                     xmltvid=strSplit2[1].toUInt();
+            }
+        }
+//        VERBOSE(VB_IMPORTANT, QString("working submit : atsc=%1 callsign=%2 dvb=%3 tv=%4 xmltvid=%5").arg(atsc).arg(callsign).arg(dvb).arg(tv).arg(xmltvid));
+        return true;
+    }
+}
Index: libs/libmyth/settings.h
===================================================================
--- libs/libmyth/settings.h	(revision 13313)
+++ libs/libmyth/settings.h	(working copy)
@@ -658,6 +658,13 @@
                        special_value_text), TransientStorage() { }
 };
 
+class MPUBLIC TransListBoxSetting :
+    public ListBoxSetting, public TransientStorage
+{
+  public:
+    TransListBoxSetting() : ListBoxSetting(this), TransientStorage() { }
+};
+
 ///////////////////////////////////////////////////////////////////////////////
 
 class MPUBLIC HostSlider : public SliderSetting, public HostDBStorage
