Changeset 3710
- Timestamp:
- 03/31/09 12:12:29 (12 months ago)
- Location:
- pcbsd/trunk
- Files:
-
- 4 modified
-
SystemUpdaterTray/UpdaterTray.cpp (modified) (9 diffs)
-
SystemUpdaterTray/UpdaterTray.h (modified) (1 diff)
-
kcmPBMsource/pbm.cpp (modified) (6 diffs)
-
kcmPBMsource/pbm.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pcbsd/trunk/SystemUpdaterTray/UpdaterTray.cpp
r3571 r3710 72 72 QString PBIProgURL3[900]; 73 73 QString PBIProgMD5[900]; 74 QString PBIProgMdate[900]; 74 75 QString PBIProgLoc[900]; 75 76 int PBIProgUpdate[900]; 76 77 int PBIProgFailed[900]; 78 QString PBIBuffer; 79 QString updatePBITextList; 77 80 78 81 void UpdaterTray::programInit() … … 480 483 if ( pbistatus == PBI_UPDATES_AVAIL ) 481 484 { 482 tooltipStr += "<br>" + tr("PBI updates available!"); 485 tooltipStr += "<br><br>" + tr("PBI updates available!") + "<br><br>"; 486 tooltipStr += updatePBITextList; 483 487 } 484 488 … … 649 653 void UpdaterTray::slotPBICheckUpdate() 650 654 { 655 // Read the buffer from the last PBI check 656 if (currentWorkingPBI != -1 ) 657 { 658 slotReadPBIBuffer(); 659 } 660 661 // Empty out our PBI buffer 662 PBIBuffer=""; 651 663 652 664 QString tmp, line; … … 715 727 716 728 checkPBIJob = KIO::http_post( PBIUrl, postData.utf8(), KIO::HideProgressInfo); 717 checkPBIJob->addMetaData("content-type", "Content-type: application/x-www-form-urlencoded" );718 719 720 729 connect(checkPBIJob, SIGNAL(result(KJob *)), this, SLOT(slotPBICheckUpdate() ) ); 721 730 connect(checkPBIJob, SIGNAL(data(KIO::Job *, const QByteArray&)), this, SLOT(slotRecieveData(KIO::Job *, const QByteArray& ) ) ); 731 checkPBIJob->addMetaData("content-type", "Content-type: application/x-www-form-urlencoded" ); 732 733 722 734 723 735 } … … 725 737 void UpdaterTray::slotRecieveData(KIO::Job*, const QByteArray& data) 726 738 { 727 QString output(data), line; 739 QString output(data); 740 PBIBuffer = PBIBuffer + output; 741 } 742 743 void UpdaterTray::slotReadPBIBuffer() 744 { 745 QString output = PBIBuffer; 746 QString line; 747 728 748 QStringList outputList; 729 749 if ( output.indexOf("Up2Date") == -1 && ! output.isEmpty()) … … 759 779 PBIProgMD5[currentWorkingPBI] = line.replace("MD5: ", ""); 760 780 } 781 if ( line.find("MDATE:") == 0) 782 { 783 PBIProgMdate[currentWorkingPBI] = line.replace("MDATE: ", ""); 784 } 761 785 } // End of For loop reading line-by-line our data 762 786 … … 777 801 int i = 0, foundUpdates = 0; 778 802 QString text, tmp, newMsg, ProgDirName, iconPath; 803 bool updateAvail; 779 804 780 805 while (! PBIProgName[i].isEmpty() ) … … 792 817 ProgDirName = ProgDirName + tmp; 793 818 iconPath = "/Programs/" + ProgDirName + "/" + PBIProgIcon[i]; 794 foundUpdates++; 819 updateAvail=true; 820 821 // Now check if we have a *newer* PBI installed here, than is in the updater 822 QFile mdatefile( "/Programs/" + ProgDirName + "/.mdate"); 823 if ( mdatefile.exists() && ! PBIProgMdate[i].isEmpty() ) 824 { 825 if ( mdatefile.open( QIODevice::ReadOnly ) ) { 826 QTextStream stream( &mdatefile ); 827 QString line; 828 line = stream.readLine(); // line of text excluding '\n' 829 if ( ! line.isEmpty() ) { 830 831 // Sort the dates from the .mdate file 832 QString tmp2 = line; 833 tmp2.truncate( tmp2.indexOf(" ") ); 834 QString date1 = tmp2; 835 tmp2 = line; 836 QString date2 = tmp2.remove( 0, tmp2.indexOf(" ") ); 837 838 // Sort the dates from the updater 839 tmp2 = PBIProgMdate[i]; 840 tmp2.truncate( tmp2.indexOf(" ") ); 841 QString PBIdate1 = tmp2; 842 tmp2 = PBIProgMdate[i]; 843 QString PBIdate2 = tmp2.remove( 0, tmp2.indexOf(" ") ); 844 845 // Check if the installed PBI is created later than the online update 846 int ldate, odate; 847 bool ok; 848 ldate = date1.toInt(&ok); 849 if ( ok ) 850 { 851 odate = PBIdate1.toInt(&ok); 852 if ( ok ) 853 { 854 if ( ldate > odate ) 855 { 856 updateAvail = false; 857 } else if (ldate == odate) { 858 // We checked the year / day, now check the hours seconds 859 ldate = date2.toInt(&ok); 860 if ( ok ) 861 { 862 odate = PBIdate2.toInt(&ok); 863 if ( ok ) 864 { 865 if ( ldate > odate ) 866 { 867 updateAvail = false; 868 } 869 } 870 } 871 } 872 } 873 } 874 875 /* QMessageBox::critical( 0, tr("Online Update"), "date1: " + date1, QMessageBox::Ok ); 876 QMessageBox::critical( 0, tr("Online Update"), "date2: " + date2, QMessageBox::Ok ); 877 QMessageBox::critical( 0, tr("Online Update"), "PBIdate1: " + PBIdate1, QMessageBox::Ok ); 878 QMessageBox::critical( 0, tr("Online Update"), "PBIdate2: " + PBIdate2, QMessageBox::Ok ); */ 879 } 880 } 881 882 883 } 884 885 // If this is a valid update, go ahead and increment our update counter 886 if ( updateAvail ) { 887 updatePBITextList = updatePBITextList + PBIProgName[i] + " " + PBIProgNewVer[i] + "<br>"; 888 foundUpdates++; 889 } 795 890 } 796 891 i++; … … 798 893 799 894 if ( foundUpdates != 0 ) { 800 // Update our dialog that we are looking for PBI updates right now 801 if (foundUpdates == 1 ) { 802 newMsg = "<font color=\"#ff0000\">" + tmp.setNum(foundUpdates) + " " + tr("PBI Update available!") + "</font>"; 803 QImage Icon2; 804 Icon2.load("/PCBSD/SystemUpdater/images/pbiupdates.png"); 805 QPixmap PixmapIcon2; 806 PixmapIcon2.convertFromImage(Icon2.scaled(22,22)); 807 808 KPassivePopup::message(tr("System Update") , tr("A PBI update is available!"), PixmapIcon2, this); 809 } else { 810 newMsg = "<font color=\"#ff0000\">" + tmp.setNum(foundUpdates) + " " + tr("PBI Updates available!") + "</font>"; 811 QImage Icon2; 812 Icon2.load("/PCBSD/SystemUpdater/images/pbiupdates.png"); 813 QPixmap PixmapIcon2; 814 PixmapIcon2.convertFromImage(Icon2.scaled(22,22)); 815 816 KPassivePopup::message(tr("System Update") , tr("PBI updates are available!"), PixmapIcon2, this); 817 } 818 895 // Set the status that we have new PBIs 819 896 pbistatus = PBI_UPDATES_AVAIL; 820 897 } else { -
pcbsd/trunk/SystemUpdaterTray/UpdaterTray.h
r3571 r3710 40 40 void slotRecieveData(KIO::Job*, const QByteArray& data); 41 41 void slotCheckAllUpdates(); 42 void slotReadPBIBuffer(); 42 43 43 44 protected: -
pcbsd/trunk/kcmPBMsource/pbm.cpp
r3164 r3710 2067 2067 { 2068 2068 2069 QString tmp, line; 2070 QString progName, Arch, Version, PBIUrl; 2069 // Read the buffer from the last PBI check 2070 if (currentWorkingPBI != -1 ) 2071 { 2072 slotReadPBIBuffer(); 2073 } 2074 2075 // Empty out our PBI buffer 2076 PBIBuffer=""; 2077 2078 QString tmp, line; 2079 QString progName, Arch, Version, PBIUrl; 2071 2080 2072 2081 … … 2129 2138 2130 2139 QString postData = "PBIName=" + progName + "&PBIVer=" + PBIProgVer[currentWorkingPBI] + "&PCBSDVER=" + Version + "&OSARCH=" + Arch; 2140 2131 2141 2142 2132 2143 checkPBIJob = KIO::http_post( PBIUrl, postData.utf8(), KIO::HideProgressInfo); 2144 connect(checkPBIJob, SIGNAL(result(KJob *)), this, SLOT(slotPBICheckUpdate() ) ); 2145 connect(checkPBIJob, SIGNAL(data(KIO::Job *, const QByteArray&)), this, SLOT(slotRecieveData(KIO::Job *, const QByteArray& ) ) ); 2146 2133 2147 checkPBIJob->addMetaData("content-type", "Content-type: application/x-www-form-urlencoded" ); 2134 2148 2135 2149 textPBIStatus->setText(tr("<font color=\"#ff0000\">Checking %1 for updates...</font>").arg(progName) ); 2136 2150 2137 connect(checkPBIJob, SIGNAL(result(KJob *)), this, SLOT(slotPBICheckUpdate() ) );2138 connect(checkPBIJob, SIGNAL(data(KIO::Job *, const QByteArray&)), this, SLOT(slotRecieveData(KIO::Job *, const QByteArray& ) ) );2139 2151 2140 2152 } … … 2142 2154 void PBM::slotRecieveData(KIO::Job*, const QByteArray& data) 2143 2155 { 2144 QString output(data), line; 2156 QString output(data); 2157 2158 PBIBuffer = PBIBuffer + output; 2159 } 2160 2161 void PBM::slotReadPBIBuffer() 2162 { 2163 QString output = PBIBuffer; 2164 QString line; 2145 2165 QStringList outputList; 2146 2166 if ( output.indexOf("Up2Date") == -1 && ! output.isEmpty()) 2147 2167 { 2168 //QMessageBox::critical( 0, tr("Online Update"), "line: " + output, QMessageBox::Ok ); 2169 2148 2170 outputList = QStringList::split("\n", output); 2149 2171 for ( int i = 0; i < outputList.size(); i++) 2150 2172 { 2151 2173 line = outputList.at(i); 2152 2174 2153 2175 if (line.find("NewVer:" ) == 0 ) 2154 2176 { … … 2176 2198 PBIProgMD5[currentWorkingPBI] = line.replace("MD5: ", ""); 2177 2199 } 2200 if ( line.find("MDATE:") == 0) 2201 { 2202 PBIProgMdate[currentWorkingPBI] = line.replace("MDATE: ", ""); 2203 } 2178 2204 } // End of For loop reading line-by-line our data 2179 2205 … … 2194 2220 int i = 0, foundUpdates = 0; 2195 2221 QString text, tmp, newMsg, ProgDirName, iconPath; 2222 bool updateAvail; 2196 2223 2197 2224 while (! PBIProgName[i].isEmpty() ) … … 2209 2236 ProgDirName = ProgDirName + tmp; 2210 2237 iconPath = "/Programs/" + ProgDirName + "/" + PBIProgIcon[i]; 2211 2212 QPixmap defaultIcon; 2213 Q3CheckListItem *item = new Q3CheckListItem ( listViewPBIUpdates, text, Q3CheckListItem::CheckBox ) ; 2214 item->setText(1, tmp.setNum(i)); 2215 2216 defaultIcon.convertFromImage(QImage(iconPath).smoothScale(32,32)); 2217 2218 item->setPixmap ( 0, defaultIcon ) ; 2219 listViewPBIUpdates->setColumnAlignment ( 0, Qt::AlignVCenter); 2220 2221 foundUpdates++; 2238 updateAvail = true; 2239 2240 // Now check if we have a *newer* PBI installed here, than is in the updater 2241 QFile mdatefile( "/Programs/" + ProgDirName + "/.mdate"); 2242 if ( mdatefile.exists() && ! PBIProgMdate[i].isEmpty() ) 2243 { 2244 if ( mdatefile.open( QIODevice::ReadOnly ) ) { 2245 Q3TextStream stream( &mdatefile ); 2246 QString line; 2247 line = stream.readLine(); // line of text excluding '\n' 2248 if ( ! line.isEmpty() ) { 2249 2250 // Sort the dates from the .mdate file 2251 QString tmp2 = line; 2252 tmp2.truncate( tmp2.indexOf(" ") ); 2253 QString date1 = tmp2; 2254 tmp2 = line; 2255 QString date2 = tmp2.remove( 0, tmp2.indexOf(" ") ); 2256 2257 // Sort the dates from the updater 2258 tmp2 = PBIProgMdate[i]; 2259 tmp2.truncate( tmp2.indexOf(" ") ); 2260 QString PBIdate1 = tmp2; 2261 tmp2 = PBIProgMdate[i]; 2262 QString PBIdate2 = tmp2.remove( 0, tmp2.indexOf(" ") ); 2263 2264 // Check if the installed PBI is created later than the online update 2265 int ldate, odate; 2266 bool ok; 2267 ldate = date1.toInt(&ok); 2268 if ( ok ) 2269 { 2270 odate = PBIdate1.toInt(&ok); 2271 if ( ok ) 2272 { 2273 if ( ldate > odate ) 2274 { 2275 updateAvail = false; 2276 } else if (ldate == odate) { 2277 // We checked the year / day, now check the hours seconds 2278 ldate = date2.toInt(&ok); 2279 if ( ok ) 2280 { 2281 odate = PBIdate2.toInt(&ok); 2282 if ( ok ) 2283 { 2284 if ( ldate > odate ) 2285 { 2286 updateAvail = false; 2287 } 2288 } 2289 } 2290 } 2291 } 2292 } 2293 2294 /* QMessageBox::critical( 0, tr("Online Update"), "date1: " + date1, QMessageBox::Ok ); 2295 QMessageBox::critical( 0, tr("Online Update"), "date2: " + date2, QMessageBox::Ok ); 2296 QMessageBox::critical( 0, tr("Online Update"), "PBIdate1: " + PBIdate1, QMessageBox::Ok ); 2297 QMessageBox::critical( 0, tr("Online Update"), "PBIdate2: " + PBIdate2, QMessageBox::Ok ); */ 2298 } 2299 } 2300 2301 2302 } 2303 2304 if ( updateAvail ) { 2305 QPixmap defaultIcon; 2306 Q3CheckListItem *item = new Q3CheckListItem ( listViewPBIUpdates, text, Q3CheckListItem::CheckBox ) ; 2307 item->setText(1, tmp.setNum(i)); 2308 2309 defaultIcon.convertFromImage(QImage(iconPath).smoothScale(32,32)); 2310 2311 item->setPixmap ( 0, defaultIcon ) ; 2312 listViewPBIUpdates->setColumnAlignment ( 0, Qt::AlignVCenter); 2313 2314 foundUpdates++; 2315 } 2222 2316 } 2223 2317 i++; -
pcbsd/trunk/kcmPBMsource/pbm.h
r3113 r3710 87 87 void slotInstallUpdatesClicked(); 88 88 void slotCheckSysUpdatesFlags(); 89 void slotReadPBIBuffer(); 89 90 private: 90 91 void RemoveFiles( PBI * pbi ); … … 168 169 QString PBIProgURL3[900]; 169 170 QString PBIProgMD5[900]; 171 QString PBIProgMdate[900]; 170 172 QString PBIProgLoc[900]; 171 173 int PBIProgUpdate[900]; 172 174 int PBIProgFailed[900]; 175 QString PBIBuffer; 173 176 signals: 174 177
