|
|
@ -15,6 +15,9 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
#include <tdelocale.h>
|
|
|
|
#include <tdelocale.h>
|
|
|
|
#include <tqtextcodec.h>
|
|
|
|
#include <tqtextcodec.h>
|
|
|
|
#include <tqmutex.h>
|
|
|
|
#include <tqmutex.h>
|
|
|
@ -132,7 +135,7 @@ void KNNntpClient::doFetchGroups()
|
|
|
|
default : status = KNGroup::unknown;
|
|
|
|
default : status = KNGroup::unknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
target->groups->append(new KNGroupInfo(name,TQString(),false,subscribed,status));
|
|
|
|
target->groups->push_back(new KNGroupInfo(name,TQString(),false,subscribed,status));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doneLines++;
|
|
|
|
doneLines++;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -140,15 +143,18 @@ void KNNntpClient::doFetchGroups()
|
|
|
|
if (!job->success() || job->canceled())
|
|
|
|
if (!job->success() || job->canceled())
|
|
|
|
return; // stopped...
|
|
|
|
return; // stopped...
|
|
|
|
|
|
|
|
|
|
|
|
TQPtrVector<KNGroupInfo> tempVector;
|
|
|
|
std::vector<KNGroupInfo*> tempVector;
|
|
|
|
target->groups->toVector(&tempVector);
|
|
|
|
for (KNGroupInfo *g : *target->groups)
|
|
|
|
tempVector.sort();
|
|
|
|
{
|
|
|
|
|
|
|
|
tempVector.push_back(g);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::sort(tempVector.begin(), tempVector.end(), KNGroupInfo::PtrCompFn);
|
|
|
|
|
|
|
|
|
|
|
|
if (target->getDescriptions) {
|
|
|
|
if (target->getDescriptions) {
|
|
|
|
errorPrefix = i18n("The group descriptions could not be retrieved.\nThe following error occurred:\n");
|
|
|
|
errorPrefix = i18n("The group descriptions could not be retrieved.\nThe following error occurred:\n");
|
|
|
|
progressValue = 100;
|
|
|
|
progressValue = 100;
|
|
|
|
doneLines = 0;
|
|
|
|
doneLines = 0;
|
|
|
|
predictedLines = target->groups->count();
|
|
|
|
predictedLines = target->groups->size();
|
|
|
|
|
|
|
|
|
|
|
|
sendSignal(TSdownloadDesc);
|
|
|
|
sendSignal(TSdownloadDesc);
|
|
|
|
sendSignal(TSprogressUpdate);
|
|
|
|
sendSignal(TSprogressUpdate);
|
|
|
@ -189,8 +195,11 @@ void KNNntpClient::doFetchGroups()
|
|
|
|
description = TQString::fromLocal8Bit(s);
|
|
|
|
description = TQString::fromLocal8Bit(s);
|
|
|
|
info.name = name;
|
|
|
|
info.name = name;
|
|
|
|
|
|
|
|
|
|
|
|
if ((pos=tempVector.bsearch(&info))!=-1)
|
|
|
|
if (std::binary_search(tempVector.begin(), tempVector.end(), &info, KNGroupInfo::PtrCompFn))
|
|
|
|
tempVector[pos]->description = description;
|
|
|
|
{
|
|
|
|
|
|
|
|
KNGroupInfo *posGroup = *std::lower_bound(tempVector.begin(), tempVector.end(), &info, KNGroupInfo::PtrCompFn);
|
|
|
|
|
|
|
|
posGroup->description = description;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doneLines++;
|
|
|
|
doneLines++;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -200,9 +209,11 @@ void KNNntpClient::doFetchGroups()
|
|
|
|
return; // stopped...
|
|
|
|
return; // stopped...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
target->groups->setAutoDelete(false);
|
|
|
|
target->groups->clear();
|
|
|
|
tempVector.toList(target->groups);
|
|
|
|
for (KNGroupInfo *g : tempVector)
|
|
|
|
target->groups->setAutoDelete(true);
|
|
|
|
{
|
|
|
|
|
|
|
|
target->groups->push_back(g);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sendSignal(TSwriteGrouplist);
|
|
|
|
sendSignal(TSwriteGrouplist);
|
|
|
|
if (!target->writeOut())
|
|
|
|
if (!target->writeOut())
|
|
|
@ -229,8 +240,7 @@ void KNNntpClient::doCheckNewGroups()
|
|
|
|
char *s, *line;
|
|
|
|
char *s, *line;
|
|
|
|
TQString name;
|
|
|
|
TQString name;
|
|
|
|
KNGroup::Status status;
|
|
|
|
KNGroup::Status status;
|
|
|
|
TQPtrList<KNGroupInfo> tmpList;
|
|
|
|
std::list<KNGroupInfo*> tmpList;
|
|
|
|
tmpList.setAutoDelete(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (getNextLine()) {
|
|
|
|
while (getNextLine()) {
|
|
|
|
line = getCurrentLine();
|
|
|
|
line = getCurrentLine();
|
|
|
@ -261,19 +271,23 @@ void KNNntpClient::doCheckNewGroups()
|
|
|
|
default : status = KNGroup::unknown;
|
|
|
|
default : status = KNGroup::unknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tmpList.append(new KNGroupInfo(name,TQString(),true,false,status));
|
|
|
|
tmpList.push_back(new KNGroupInfo(name,TQString(),true,false,status));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doneLines++;
|
|
|
|
doneLines++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool statusOk = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (!job->success() || job->canceled())
|
|
|
|
if (!job->success() || job->canceled())
|
|
|
|
return; // stopped...
|
|
|
|
{
|
|
|
|
|
|
|
|
statusOk = false; // stopped...
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (target->getDescriptions) {
|
|
|
|
if (statusOk && target->getDescriptions) {
|
|
|
|
errorPrefix = i18n("The group descriptions could not be retrieved.\nThe following error occurred:\n");
|
|
|
|
errorPrefix = i18n("The group descriptions could not be retrieved.\nThe following error occurred:\n");
|
|
|
|
progressValue = 100;
|
|
|
|
progressValue = 100;
|
|
|
|
doneLines = 0;
|
|
|
|
doneLines = 0;
|
|
|
|
predictedLines = tmpList.count()*3;
|
|
|
|
predictedLines = tmpList.size()*3;
|
|
|
|
|
|
|
|
|
|
|
|
sendSignal(TSdownloadDesc);
|
|
|
|
sendSignal(TSdownloadDesc);
|
|
|
|
sendSignal(TSprogressUpdate);
|
|
|
|
sendSignal(TSprogressUpdate);
|
|
|
@ -283,14 +297,21 @@ void KNNntpClient::doCheckNewGroups()
|
|
|
|
char *s;
|
|
|
|
char *s;
|
|
|
|
int rep;
|
|
|
|
int rep;
|
|
|
|
|
|
|
|
|
|
|
|
for (KNGroupInfo *group=tmpList.first(); group; group=tmpList.next()) {
|
|
|
|
for (KNGroupInfo *group : tmpList)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!sendCommand(cmd+group->name.utf8(),rep))
|
|
|
|
if (!sendCommand(cmd+group->name.utf8(),rep))
|
|
|
|
return;
|
|
|
|
{
|
|
|
|
|
|
|
|
statusOk = false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (rep != 215) // 215 informations follows
|
|
|
|
if (rep != 215) // 215 informations follows
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
desList.clear();
|
|
|
|
desList.clear();
|
|
|
|
if (!getMsg(desList))
|
|
|
|
if (!getMsg(desList))
|
|
|
|
return;
|
|
|
|
{
|
|
|
|
|
|
|
|
statusOk = false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (desList.count()>0) { // group has a description
|
|
|
|
if (desList.count()>0) { // group has a description
|
|
|
|
s = desList.first();
|
|
|
|
s = desList.first();
|
|
|
@ -310,17 +331,26 @@ void KNNntpClient::doCheckNewGroups()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sendSignal(TSloadGrouplist);
|
|
|
|
if (statusOk)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sendSignal(TSloadGrouplist);
|
|
|
|
|
|
|
|
|
|
|
|
if (!target->readIn()) {
|
|
|
|
if (!target->readIn()) {
|
|
|
|
job->setErrorString(i18n("Unable to read the group list file"));
|
|
|
|
job->setErrorString(i18n("Unable to read the group list file"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
target->merge(&tmpList);
|
|
|
|
|
|
|
|
sendSignal(TSwriteGrouplist);
|
|
|
|
|
|
|
|
if (!target->writeOut()) {
|
|
|
|
|
|
|
|
job->setErrorString(i18n("Unable to write the group list file"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
target->merge(&tmpList);
|
|
|
|
|
|
|
|
sendSignal(TSwriteGrouplist);
|
|
|
|
for (KNGroupInfo *group : tmpList)
|
|
|
|
if (!target->writeOut()) {
|
|
|
|
{
|
|
|
|
job->setErrorString(i18n("Unable to write the group list file"));
|
|
|
|
delete group;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|