KIO error system question
Hamish Rodda
meddie at yoyo.its.monash.edu.au
Tue Apr 9 12:21:45 BST 2002
I'm in the process of working in a way for kioslaves to report errors in
detail to fit in with the error documentation work I did a while back. What
I'm trying to accomplish is the following:
When a slave emits error(), it sends a QString errorText. I want to be able to
send more structured data (a few QStrings and QStringLists) through
errorText, and tried creating a QByteArray and QDataStream in order to stream
these objects into the errorText QString.
The problem is that the resulting QByteArray has lots of zero-value chars in
it, so when the QString is created to send back, it is of length zero.
Can anyone think of a fix for this (or a better way to do it)?
Thanks,
Hamish.
Data I'm trying to pass:
QString errorName - the name of the error
QString techName - if not null, the technical name of the error
QString description - a description of the error
QStringList causes - a list of possible causes of the error
QStringList solutions - a list of possible solutions for the error
Example code:
On the IOSlave side:
QByteArray data;
QDataStream stream( data, IO_WriteOnly );
stream << customErrorName << customTechName << customDescription
<< customCauses << customSolutions;
// Here the errorString is empty as data starts with a few zero-value chars
errorString = QString::fromUtf8( data );
error(ERR_CUSTOM, errorString);
On the receiving side:
QByteArray input = errorText.utf8();
QDataStream stream(input, IO_ReadOnly);
stream >> errorName;
stream >> techName;
stream >> description;
stream >> causes;
stream >> solutions;
More information about the kfm-devel
mailing list