~ubuntu-branches/ubuntu/quantal/ark/quantal

« back to all changes in this revision

Viewing changes to plugins/cliplugin-example/cliplugin.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-06-06 18:50:49 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120606185049-z43lsy5wwp3wtrgt
Tags: 4:4.8.80-0ubuntu1
* Merge with Debian git repository, remaining changes:
  - Suggest instead of recommend p7zip-full
  - Add and install utilities-file-archiver.xpm
* New upstream beta release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
    if (p.isEmpty()) {
49
49
        p[CaptureProgress] = true;
50
 
        p[ListProgram] = p[ExtractProgram] = p[DeleteProgram] = p[AddProgram] = "rar";
51
 
 
52
 
        p[ListArgs] = QStringList() << "v" << "-c-" << "$Archive";
53
 
        p[ExtractArgs] = QStringList() << "-p-" << "$PreservePathSwitch" << "$PasswordSwitch" << "$RootNodeSwitch" << "$Archive" << "$Files";
54
 
        p[PreservePathSwitch] = QStringList() << "x" << "e";
55
 
        p[RootNodeSwitch] = QStringList() << "-ap$Path";
56
 
        p[PasswordSwitch] = QStringList() << "-p$Password";
57
 
 
58
 
        p[DeleteArgs] = QStringList() << "d" << "$Archive" << "$Files";
59
 
 
60
 
        p[FileExistsExpression] = "^(.+) already exists. Overwrite it";
 
50
        p[ListProgram] = p[ExtractProgram] = p[DeleteProgram] = p[AddProgram] = QLatin1String("rar");
 
51
 
 
52
        p[ListArgs] = QStringList() << QLatin1String("v") << QLatin1String("-c-") << QLatin1String("$Archive");
 
53
        p[ExtractArgs] = QStringList() << QLatin1String("-p-") << QLatin1String("$PreservePathSwitch") << QLatin1String("$PasswordSwitch") << QLatin1String("$RootNodeSwitch") << QLatin1String("$Archive") << QLatin1String("$Files");
 
54
        p[PreservePathSwitch] = QStringList() << QLatin1String("x") << QLatin1String("e");
 
55
        p[RootNodeSwitch] = QStringList() << QLatin1String("-ap$Path");
 
56
        p[PasswordSwitch] = QStringList() << QLatin1String("-p$Password");
 
57
 
 
58
        p[DeleteArgs] = QStringList() << QLatin1String("d") << QLatin1String("$Archive") << QLatin1String("$Files");
 
59
 
 
60
        p[FileExistsExpression] = QLatin1String("^(.+) already exists. Overwrite it");
61
61
        p[FileExistsInput] = QStringList()
62
 
                                << "Y" //overwrite
63
 
                                << "N" //skip
64
 
                                << "A" //overwrite all
65
 
                                << "E" //autoskip
66
 
                                << "Q" //cancel
 
62
                                << QLatin1String("Y") //overwrite
 
63
                                << QLatin1String("N") //skip
 
64
                                << QLatin1String("A") //overwrite all
 
65
                                << QLatin1String("E") //autoskip
 
66
                                << QLatin1String("Q") //cancel
67
67
                                ;
68
68
 
69
 
        p[AddArgs] = QStringList() << "a" << "$Archive" << "$Files";
 
69
        p[AddArgs] = QStringList() << QLatin1String("a") << QLatin1String("$Archive") << QLatin1String("$Files");
70
70
 
71
 
        p[WrongPasswordPatterns] = QStringList() << "password incorrect";
72
 
        p[ExtractionFailedPatterns] = QStringList() << "CRC failed";
 
71
        p[WrongPasswordPatterns] = QStringList() << QLatin1String("password incorrect");
 
72
        p[ExtractionFailedPatterns] = QStringList() << QLatin1String("CRC failed");
73
73
    }
74
74
 
75
75
    return p;
77
77
 
78
78
bool CliPlugin::readListLine(const QString &line)
79
79
{
80
 
    const QString m_headerString = "-----------------------------------------";
 
80
    const QString m_headerString = QLatin1String("-----------------------------------------");
81
81
 
82
82
    // skip the heading
83
83
    if (!m_incontent) {
97
97
    if (m_isFirstLine) {
98
98
        m_internalId = line.trimmed();
99
99
        //m_entryFilename.chop(1); // handle newline
100
 
        if (!m_internalId.isEmpty() && m_internalId.at(0) == '*') {
 
100
        if (!m_internalId.isEmpty() && m_internalId.at(0) == QLatin1Char('*')) {
101
101
            m_isPasswordProtected = true;
102
102
            m_internalId.remove(0, 1);   // and the spaces in front
103
103
        } else
107
107
        return true;
108
108
    }
109
109
 
110
 
    QStringList fileprops = line.split(' ', QString::SkipEmptyParts);
 
110
    QStringList fileprops = line.split(QLatin1Char(' '), QString::SkipEmptyParts);
111
111
    m_internalId = QDir::fromNativeSeparators(m_internalId);
112
 
    bool isDirectory = (bool)(fileprops[ 5 ].contains('d', Qt::CaseInsensitive));
 
112
    bool isDirectory = (bool)(fileprops[ 5 ].contains(QLatin1Char('d'), Qt::CaseInsensitive));
113
113
 
114
 
    QDateTime ts(QDate::fromString(fileprops[ 3 ], "dd-MM-yy"),
115
 
                    QTime::fromString(fileprops[ 4 ], "hh:mm"));
 
114
    QDateTime ts(QDate::fromString(fileprops[ 3 ], QLatin1String("dd-MM-yy")),
 
115
                 QTime::fromString(fileprops[ 4 ], QLatin1String("hh:mm")));
116
116
    // rar output date with 2 digit year but QDate takes is as 19??
117
117
    // let's take 1950 is cut-off; similar to KDateTime
118
118
    if (ts.date().year() < 1950) {
120
120
    }
121
121
 
122
122
    m_entryFilename = m_internalId;
123
 
    if (isDirectory && !m_internalId.endsWith('/')) {
124
 
        m_entryFilename += '/';
 
123
    if (isDirectory && !m_internalId.endsWith(QLatin1Char('/'))) {
 
124
        m_entryFilename += QLatin1Char('/');
125
125
    }
126
126
 
127
127
    //kDebug() << m_entryFilename << " : " << fileprops;
140
140
    e[ IsPasswordProtected] = m_isPasswordProtected;
141
141
    kDebug() << "Added entry: " << e;
142
142
 
143
 
    entry(e);
 
143
    emit entry(e);
144
144
    m_isFirstLine = true;
145
145
    return true;
146
146
}