Rework cma protocol selection.
Read plugins from current application directory on debug mode.
This commit is contained in:
		@@ -24,7 +24,7 @@ SOURCES += \
 | 
			
		||||
    src/sqlitedb.cpp \
 | 
			
		||||
    src/httpdownloader.cpp \
 | 
			
		||||
    src/qlistdb.cpp \
 | 
			
		||||
    src/database.cpp \
 | 
			
		||||
    src/database.cpp
 | 
			
		||||
 | 
			
		||||
HEADERS += \
 | 
			
		||||
    src/capability.h \
 | 
			
		||||
@@ -40,7 +40,7 @@ HEADERS += \
 | 
			
		||||
    src/sqlitedb.h \
 | 
			
		||||
    src/httpdownloader.h \
 | 
			
		||||
    src/qlistdb.h \
 | 
			
		||||
    src/database.h \
 | 
			
		||||
    src/database.h
 | 
			
		||||
 | 
			
		||||
OTHER_FILES += \
 | 
			
		||||
    resources/xml/psp2-updatelist.xml \
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,11 @@ bool DeviceCapability::exchangeInfo(vita_device_t *device)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QString hostname = QHostInfo::localHostName();
 | 
			
		||||
 | 
			
		||||
    int protocol_version = ::getVitaProtocolVersion();
 | 
			
		||||
 | 
			
		||||
    qDebug() << "Sending Qcma protocol version:" << protocol_version;
 | 
			
		||||
 | 
			
		||||
    const initiator_info_t *pc_info = VitaMTP_Data_Initiator_New(hostname.toUtf8().data(), protocol_version);
 | 
			
		||||
 | 
			
		||||
    // Next, we send the client's (this program) info (discard the const here)
 | 
			
		||||
 
 | 
			
		||||
@@ -188,20 +188,14 @@ QString readable_size(qint64 size, bool use_gib)
 | 
			
		||||
 | 
			
		||||
int getVitaProtocolVersion()
 | 
			
		||||
{
 | 
			
		||||
    bool useCustom = QSettings().value("useCustomProtocol").toBool();
 | 
			
		||||
    if(useCustom)
 | 
			
		||||
    {
 | 
			
		||||
        bool ok;
 | 
			
		||||
        int protocol = QSettings().value("protocolVersion").toInt(&ok);
 | 
			
		||||
        if(ok && protocol > 0)
 | 
			
		||||
            return protocol;
 | 
			
		||||
        else
 | 
			
		||||
            return VITAMTP_PROTOCOL_MAX_VERSION;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
    QString protocol_mode = QSettings().value("protocolMode", "automatic").toString();
 | 
			
		||||
 | 
			
		||||
    int protocol;
 | 
			
		||||
 | 
			
		||||
    if(protocol_mode == "manual")
 | 
			
		||||
    {
 | 
			
		||||
        int index = QSettings().value("protocolIndex").toInt();
 | 
			
		||||
 | 
			
		||||
        switch(index)
 | 
			
		||||
        {
 | 
			
		||||
        case 0:
 | 
			
		||||
@@ -223,13 +217,32 @@ int getVitaProtocolVersion()
 | 
			
		||||
            protocol = VITAMTP_PROTOCOL_FW_2_00;
 | 
			
		||||
            break;
 | 
			
		||||
        case 6:
 | 
			
		||||
            protocol = VITAMTP_WIRELESS_FW_2_00;
 | 
			
		||||
            protocol = 1300010; // VITAMTP_PROTOCOL_FW_1_80
 | 
			
		||||
            break;
 | 
			
		||||
        case 7:
 | 
			
		||||
            protocol = 1200010; // VITAMTP_PROTOCOL_FW_1_60
 | 
			
		||||
            break;
 | 
			
		||||
        case 8:
 | 
			
		||||
            protocol = 1100010; // VITAMTP_PROTOCOL_FW_1_50
 | 
			
		||||
            break;
 | 
			
		||||
        case 9:
 | 
			
		||||
            protocol = 1000010; // VITAMTP_PROTOCOL_FW_1_00
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            protocol = VITAMTP_PROTOCOL_MAX_VERSION;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if(protocol_mode == "custom")
 | 
			
		||||
    {
 | 
			
		||||
        bool ok;
 | 
			
		||||
        int protocol = QSettings().value("protocolVersion").toInt(&ok);
 | 
			
		||||
 | 
			
		||||
        if(!ok || protocol <= 0)
 | 
			
		||||
            protocol = VITAMTP_PROTOCOL_MAX_VERSION;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
        protocol = VITAMTP_PROTOCOL_MAX_VERSION;
 | 
			
		||||
 | 
			
		||||
    return protocol;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,32 @@ void ConfigWidget::connectSignals()
 | 
			
		||||
    connect(mapper, SIGNAL(mapped(int)), this, SLOT(browseBtnPressed(int)));
 | 
			
		||||
    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
 | 
			
		||||
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
 | 
			
		||||
 | 
			
		||||
    connect(ui->protocolModeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolModeChanged(int)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfigWidget::protocolModeChanged(int index)
 | 
			
		||||
{
 | 
			
		||||
    switch(index)
 | 
			
		||||
    {
 | 
			
		||||
    case 0:
 | 
			
		||||
        ui->protocolBox->setEnabled(false);
 | 
			
		||||
        ui->protocolEdit->setEnabled(false);
 | 
			
		||||
        break;
 | 
			
		||||
    case 1:
 | 
			
		||||
        ui->protocolBox->setEnabled(true);
 | 
			
		||||
        ui->protocolEdit->setEnabled(false);
 | 
			
		||||
        break;
 | 
			
		||||
    case 2:
 | 
			
		||||
        ui->protocolBox->setEnabled(false);
 | 
			
		||||
        ui->protocolEdit->setEnabled(true);
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        ui->protocolBox->setEnabled(false);
 | 
			
		||||
        ui->protocolEdit->setEnabled(false);
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfigWidget::setDefaultData()
 | 
			
		||||
@@ -99,7 +125,17 @@ void ConfigWidget::setDefaultData()
 | 
			
		||||
    ui->videoSkipCheck->setChecked(settings.value("videoSkip", false).toBool());
 | 
			
		||||
    ui->musicSkipCheck->setChecked(settings.value("musicSkip", false).toBool());
 | 
			
		||||
 | 
			
		||||
    ui->customProtocolCheckBox->setChecked(settings.value("useCustomProtocol", false).toBool());
 | 
			
		||||
    QString protocol_mode = settings.value("protocolMode", "automatic").toString();
 | 
			
		||||
 | 
			
		||||
    if(protocol_mode == "manual")
 | 
			
		||||
        ui->protocolModeBox->setCurrentIndex(1);
 | 
			
		||||
    else if(protocol_mode == "custom")
 | 
			
		||||
        ui->protocolModeBox->setCurrentIndex(2);
 | 
			
		||||
    else
 | 
			
		||||
        ui->protocolModeBox->setCurrentIndex(0);
 | 
			
		||||
 | 
			
		||||
    protocolModeChanged(ui->protocolModeBox->currentIndex());
 | 
			
		||||
 | 
			
		||||
    ui->protocolBox->setCurrentIndex(settings.value("protocolIndex", 0).toInt());
 | 
			
		||||
 | 
			
		||||
    bool ok;
 | 
			
		||||
@@ -190,9 +226,15 @@ void ConfigWidget::accept()
 | 
			
		||||
    settings.setValue("photoSkip", ui->photoSkipCheck->isChecked());
 | 
			
		||||
    settings.setValue("videoSkip", ui->videoSkipCheck->isChecked());
 | 
			
		||||
    settings.setValue("musicSkip", ui->musicSkipCheck->isChecked());
 | 
			
		||||
    settings.setValue("useCustomProtocol", ui->customProtocolCheckBox->isChecked());
 | 
			
		||||
    settings.setValue("protocolIndex", ui->protocolBox->currentIndex());
 | 
			
		||||
 | 
			
		||||
    if(ui->protocolModeBox->currentIndex() == 0)
 | 
			
		||||
        settings.setValue("protocolMode", "automatic");
 | 
			
		||||
    else if(ui->protocolModeBox->currentIndex() == 1)
 | 
			
		||||
        settings.setValue("protocolMode", "manual");
 | 
			
		||||
    else if(ui->protocolModeBox->currentIndex() == 2)
 | 
			
		||||
        settings.setValue("protocolMode", "custom");
 | 
			
		||||
 | 
			
		||||
    bool ok;
 | 
			
		||||
    int protocol = ui->protocolEdit->text().toInt(&ok);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,7 @@ private:
 | 
			
		||||
    Ui::ConfigWidget *ui;
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void protocolModeChanged(int index);
 | 
			
		||||
    void browseBtnPressed(int from);
 | 
			
		||||
    void accept();
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -6,8 +6,8 @@
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>532</width>
 | 
			
		||||
    <height>457</height>
 | 
			
		||||
    <width>519</width>
 | 
			
		||||
    <height>525</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
@@ -375,17 +375,17 @@
 | 
			
		||||
             <property name="fieldGrowthPolicy">
 | 
			
		||||
              <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
 | 
			
		||||
             </property>
 | 
			
		||||
             <item row="0" column="0">
 | 
			
		||||
             <item row="1" column="0">
 | 
			
		||||
              <widget class="QLabel" name="label_10">
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>CMA Protocol version</string>
 | 
			
		||||
                <string>CMA protocol version</string>
 | 
			
		||||
               </property>
 | 
			
		||||
               <property name="alignment">
 | 
			
		||||
                <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="0" column="1">
 | 
			
		||||
             <item row="1" column="1">
 | 
			
		||||
              <widget class="QComboBox" name="protocolBox">
 | 
			
		||||
               <property name="minimumSize">
 | 
			
		||||
                <size>
 | 
			
		||||
@@ -425,34 +425,27 @@
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>FW 1.80 - 1300010</string>
 | 
			
		||||
                 <string notr="true">FW 1.80 - 1300010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>FW 1.60 - 1200010</string>
 | 
			
		||||
                 <string notr="true">FW 1.60 - 1200010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>FW 1.50 - 1100010</string>
 | 
			
		||||
                 <string notr="true">FW 1.50 - 1100010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>FW 1.00 - 1000010</string>
 | 
			
		||||
                 <string notr="true">FW 1.00 - 1000010</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="1" column="0">
 | 
			
		||||
              <widget class="QCheckBox" name="customProtocolCheckBox">
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>Use custom version</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="1" column="1">
 | 
			
		||||
             <item row="2" column="1">
 | 
			
		||||
              <widget class="QLineEdit" name="protocolEdit">
 | 
			
		||||
               <property name="inputMask">
 | 
			
		||||
                <string notr="true">9999999</string>
 | 
			
		||||
@@ -462,6 +455,39 @@
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="0" column="0">
 | 
			
		||||
              <widget class="QLabel" name="label_11">
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>CMA protocol selection</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="0" column="1">
 | 
			
		||||
              <widget class="QComboBox" name="protocolModeBox">
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>Latest</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>Manual</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
               <item>
 | 
			
		||||
                <property name="text">
 | 
			
		||||
                 <string>Custom</string>
 | 
			
		||||
                </property>
 | 
			
		||||
               </item>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
             <item row="2" column="0">
 | 
			
		||||
              <widget class="QLabel" name="label_12">
 | 
			
		||||
               <property name="text">
 | 
			
		||||
                <string>CMA custom version</string>
 | 
			
		||||
               </property>
 | 
			
		||||
              </widget>
 | 
			
		||||
             </item>
 | 
			
		||||
            </layout>
 | 
			
		||||
           </item>
 | 
			
		||||
           <item>
 | 
			
		||||
 
 | 
			
		||||
@@ -215,14 +215,21 @@ void MainWidget::refreshDatabase()
 | 
			
		||||
TrayIndicator *MainWidget::createTrayObject(QWidget *parent)
 | 
			
		||||
{
 | 
			
		||||
    TrayFunctionPointer create_tray = NULL;
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_LINUX
 | 
			
		||||
    QString desktop = getenv("XDG_CURRENT_DESKTOP");
 | 
			
		||||
    qDebug() << "Current desktop: " << desktop;
 | 
			
		||||
 | 
			
		||||
#ifdef QT_DEBUG
 | 
			
		||||
    QString library_path = QApplication::applicationDirPath();
 | 
			
		||||
#else
 | 
			
		||||
    QString library_path = "/usr/lib/qcma";
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if(desktop.toLower() == "kde")
 | 
			
		||||
    {
 | 
			
		||||
        // KDENotifier
 | 
			
		||||
        QLibrary library("/usr/lib/qcma/libqcma_kdenotifier.so");
 | 
			
		||||
        QLibrary library(library_path + "/libqcma_kdenotifier.so");
 | 
			
		||||
        if(library.load())
 | 
			
		||||
            create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
 | 
			
		||||
        else
 | 
			
		||||
@@ -233,7 +240,7 @@ TrayIndicator *MainWidget::createTrayObject(QWidget *parent)
 | 
			
		||||
    // if(desktop.toLower() == "unity")
 | 
			
		||||
    {
 | 
			
		||||
        // AppIndicator
 | 
			
		||||
        QLibrary library("/usr/lib/qcma/libqcma_appindicator.so");
 | 
			
		||||
        QLibrary library(library_path + "/libqcma_appindicator.so");
 | 
			
		||||
        if(library.load())
 | 
			
		||||
            create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
 | 
			
		||||
        else
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ class TrayIndicator : public QWidget
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    virtual ~TrayIndicator() {}
 | 
			
		||||
    ~TrayIndicator() {}
 | 
			
		||||
    virtual void init() = 0;
 | 
			
		||||
    virtual bool isVisible() = 0;
 | 
			
		||||
    virtual void setIcon(const QString &icon) = 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user