summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp')
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp83
1 files changed, 50 insertions, 33 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp b/rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp
index 013549d037..32cc3c4cf1 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp
@@ -42,34 +42,6 @@ QString BootloaderInstallChinaChip::ofHint()
42 "file."); 42 "file.");
43} 43}
44 44
45void BootloaderInstallChinaChip::logString(char* format, va_list args, int type)
46{
47 QString translation = QCoreApplication::translate("", format, NULL, QCoreApplication::UnicodeUTF8);
48
49 emit logItem(QString().vsprintf(translation.toLocal8Bit(), args), type);
50 QCoreApplication::processEvents();
51}
52
53static void info(void* userdata, char* format, ...)
54{
55 BootloaderInstallChinaChip* pThis = (BootloaderInstallChinaChip*) userdata;
56 va_list args;
57
58 va_start(args, format);
59 pThis->logString(format, args, LOGINFO);
60 va_end(args);
61}
62
63static void err(void* userdata, char* format, ...)
64{
65 BootloaderInstallChinaChip* pThis = (BootloaderInstallChinaChip*) userdata;
66 va_list args;
67
68 va_start(args, format);
69 pThis->logString(format, args, LOGERROR);
70 va_end(args);
71}
72
73bool BootloaderInstallChinaChip::install() 45bool BootloaderInstallChinaChip::install()
74{ 46{
75 if(m_offile.isEmpty()) 47 if(m_offile.isEmpty())
@@ -85,17 +57,62 @@ bool BootloaderInstallChinaChip::install()
85 57
86void BootloaderInstallChinaChip::installStage2() 58void BootloaderInstallChinaChip::installStage2()
87{ 59{
60 enum cc_error result;
61 bool error = true;
88 m_tempfile.open(); 62 m_tempfile.open();
89 QString blfile = m_tempfile.fileName(); 63 QString blfile = m_tempfile.fileName();
90 m_tempfile.close(); 64 m_tempfile.close();
91 65
92 QString backupfile = QFileInfo(m_blfile).absoluteDir().absoluteFilePath("ccpmp.bin"); 66 QString backupfile = QFileInfo(m_blfile).absoluteDir().absoluteFilePath("ccpmp.bin");
93 67
94 int ret = chinachip_patch(m_offile.toLocal8Bit(), blfile.toLocal8Bit(), m_blfile.toLocal8Bit(), 68 result = chinachip_patch(m_offile.toLocal8Bit(), blfile.toLocal8Bit(),
95 backupfile.toLocal8Bit(), &info, &err, (void*)this); 69 m_blfile.toLocal8Bit(), backupfile.toLocal8Bit());
96 qDebug() << "chinachip_patch" << ret; 70 switch(result) {
97 71 case E_OK:
98 emit done(ret); 72 error = false;
73 break;
74 case E_OPEN_FIRMWARE:
75 emit logItem(tr("Could not open firmware file"), LOGERROR);
76 break;
77 case E_OPEN_BOOTLOADER:
78 emit logItem(tr("Could not open bootloader file"), LOGERROR);
79 break;
80 case E_MEMALLOC:
81 emit logItem(tr("Could not allocate memory"), LOGERROR);
82 break;
83 case E_LOAD_FIRMWARE:
84 emit logItem(tr("Could not load firmware file"), LOGERROR);
85 break;
86 case E_INVALID_FILE:
87 emit logItem(tr("File is not a valid ChinaChip firmware"), LOGERROR);
88 break;
89 case E_NO_CCPMP:
90 emit logItem(tr("Could not find ccpmp.bin in input file"), LOGERROR);
91 break;
92 case E_OPEN_BACKUP:
93 emit logItem(tr("Could not open backup file for ccpmp.bin"), LOGERROR);
94 break;
95 case E_WRITE_BACKUP:
96 emit logItem(tr("Could not write backup file for ccpmp.bin"), LOGERROR);
97 break;
98 case E_LOAD_BOOTLOADER:
99 emit logItem(tr("Could not load bootloader file"), LOGERROR);
100 break;
101 case E_GET_TIME:
102 emit logItem(tr("Could not get current time"), LOGERROR);
103 break;
104 case E_OPEN_OUTFILE:
105 emit logItem(tr("Could not open output file"), LOGERROR);
106 break;
107 case E_WRITE_OUTFILE:
108 emit logItem(tr("Could not write output file"), LOGERROR);
109 break;
110 default:
111 emit logItem(tr("Unexpected error from chinachippatcher"), LOGERROR);
112 break;
113 }
114
115 emit done(error);
99} 116}
100 117
101bool BootloaderInstallChinaChip::uninstall() 118bool BootloaderInstallChinaChip::uninstall()