summaryrefslogtreecommitdiff
authorerik <erik>2007-01-10 17:31:08 (UTC)
committer erik <erik>2007-01-10 17:31:08 (UTC)
commit6825f30b665952864dbe35fe8329a0e4c264d4b8 (patch) (side-by-side diff)
tree7c8d178f835d4a7d294b6ef65e0040c40579e84e
parentd8e580a239ab84fbe063b2f3779d417598d5ca0a (diff)
downloadopie-6825f30b665952864dbe35fe8329a0e4c264d4b8.zip
opie-6825f30b665952864dbe35fe8329a0e4c264d4b8.tar.gz
opie-6825f30b665952864dbe35fe8329a0e4c264d4b8.tar.bz2
All of the files included have instances where an array is new'ed but
the corresponding delete does not have the corresponding [] argument.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEScreen.cpp4
-rw-r--r--noncore/apps/checkbook/listedit.cpp2
-rw-r--r--noncore/apps/opie-console/TEScreen.cpp4
-rw-r--r--noncore/apps/opie-sheet/Excel.cpp2
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp4
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp6
-rw-r--r--noncore/games/sfcave/sfcave.cpp2
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp2
-rw-r--r--noncore/settings/aqpkg/version.cpp2
9 files changed, 14 insertions, 14 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp
index 8e69a88..1db34d2 100644
--- a/core/apps/embeddedkonsole/TEScreen.cpp
+++ b/core/apps/embeddedkonsole/TEScreen.cpp
@@ -1045,192 +1045,192 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks)
s++;
}
if (s <= sel_BR)
{
// The line break handling
// It's different from the screen
// image case!
if (eol % columns == 0)
{
// That's either a completely filled
// line or an empty line
if (eol == 0)
{
m[d++] = '\n';
}
else
{
// We have a full line.
// FIXME: How can we handle newlines
// at this position?!
}
}
else if ((eol + 1) % columns == 0)
{
// FIXME: We don't know if this was a
// space at the last position or a
// short line!!
m[d++] = ' ';
}
else
{
// We have a short line here. Put a
// newline or a space into the
// buffer.
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
hY++;
hX = 0;
s = hY * columns;
}
else
{ // or from screen image.
eol = (s / columns + 1) * columns - 1;
if (eol < sel_BR)
{
while ((eol > s) &&
isspace(image[eol - hist_BR].c))
{
eol--;
}
}
else
{
eol = sel_BR;
}
while (s <= eol)
{
m[d++] = image[s++ - hist_BR].c;
}
if (eol < sel_BR)
{
// eol processing see below ...
if ((eol + 1) % columns == 0)
{
if (image[eol - hist_BR].c == ' ')
{
m[d++] = ' ';
}
}
else
{
m[d++] = ((preserve_line_breaks ||
((eol % columns) == 0)) ?
'\n' : ' ');
}
}
s = (eol / columns + 1) * columns;
}
}
QChar* qc = new QChar[d];
for (int i = 0; i < d; i++)
{
qc[i] = m[i];
}
QString res(qc, d);
- delete m;
- delete qc;
+ delete [] m;
+ delete [] qc;
return res;
}
/* above ... end of line processing for selection -- psilva
cases:
1) (eol+1)%columns == 0 --> the whole line is filled.
If the last char is a space, insert (preserve) space. otherwise
leave the text alone, so that words that are broken by linewrap
are preserved.
FIXME:
* this suppresses \n for command output that is
sized to the exact column width of the screen.
2) eol%columns == 0 --> blank line.
insert a \n unconditionally.
Do it either you would because you are in preserve_line_break mode,
or because it's an ASCII paragraph delimiter, so even when
not preserving line_breaks, you want to preserve paragraph breaks.
3) else --> partially filled line
insert a \n in preserve line break mode, else a space
The space prevents concatenation of the last word of one
line with the first of the next.
*/
void TEScreen::addHistLine()
{
assert(hasScroll() || histCursor == 0);
// add to hist buffer
// we have to take care about scrolling, too...
if (hasScroll()){
ca dft;
int end = columns - 1;
while (end >= 0 && image[end] == dft)
end -= 1;
hist.addCells( image, end + 1);
hist.addLine();
// adjust history cursor
histCursor += ( hist.getLines() - 1 == histCursor);
}
if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround
}
void TEScreen::setHistCursor(int cursor)
{
histCursor = cursor; //FIXME:rangecheck
if (histCursor > hist.getLines()) {
histCursor = hist.getLines();
}
if (histCursor < 0) {
histCursor = 0;
}
}
void TEScreen::setHorzCursor(int cursor)
{
horzCursor = cursor;
}
int TEScreen::getHistCursor()
{
return histCursor;
}
int TEScreen::getHorzCursor()
{
return horzCursor;
}
int TEScreen::getHistLines()
{
return hist.getLines();
}
void TEScreen::setScroll(bool on)
{
histCursor = 0;
clearSelection();
hist.setScroll(on);
}
bool TEScreen::hasScroll()
{
return hist.hasScroll();
}
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp
index e40377b..b297d69 100644
--- a/noncore/apps/checkbook/listedit.cpp
+++ b/noncore/apps/checkbook/listedit.cpp
@@ -143,193 +143,193 @@ void ListEdit::slotDel()
_stack->raiseWidget(_typeEdit);
}
// --- fixTypes ----------------------------------------------------------------
// Makes sure all entries have a unique name and empty entries are replaced
// by a generic string. The first version performs the operation on a particular
// column, whereas the 2nd does it for all unique columns.
class ColMap {
public:
ColMap(QString sValue, QListViewItem *pEntry) {
_sValue=sValue;
_pEntry=pEntry;
}
QString &getValue() { return(_sValue); }
QListViewItem *getItem() { return(_pEntry); }
protected:
QString _sValue;
QListViewItem *_pEntry;
};
class ColList : public QList<QString>
{
public:
ColList() : QList<QString>() { }
protected:
int compareItems(QCollection::Item, QCollection::Item);
};
int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) {
return( ((QString *)i1)->compare(*(QString *)i2) );
}
void ListEdit::fixTypes(int iColumn)
{
// get column def
ColumnDef *pDef=this->at(iColumn);
// create map of entries
if( !_typeTable->childCount() ) return;
ColMap **colMap=new ColMap *[_typeTable->childCount()];
QListViewItem *cur=_typeTable->firstChild();
ColList lst;
for(int i=0; i<_typeTable->childCount(); i++) {
colMap[i]=new ColMap(cur->text(iColumn), cur);
lst.append( &(colMap[i]->getValue()) );
cur=cur->nextSibling();
}
// fix empty entries
int i=0;
for(QString *ptr=lst.first(); ptr; ptr=lst.next()) {
*ptr=ptr->stripWhiteSpace();
if( ptr->isEmpty() ) {
i++;
if( i==1 ) *ptr=pDef->getNewValue();
else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i);
}
}
// fix dups
lst.sort();
QString repl;
for(uint iCur=0; iCur<lst.count()-1; iCur++) {
QString *current=lst.at(iCur);
for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) {
if( *current!=*lst.at(iNext) ) continue;
for(int i=2; ; i++) {
repl.sprintf("%s %d", (const char *)*current, i);
bool bDup=false;
uint iChk=iNext+1;
while( iChk<lst.count() ) {
QString *chk=lst.at(iChk);
if( !chk->startsWith(*current) ) break;
if( *chk==repl ) {
bDup=true;
break;
}
iChk++;
}
if( !bDup ) {
*lst.at(iNext)=repl;
break;
}
}
}
}
lst.sort();
// copy back clean up col map
for(int i=0; i<_typeTable->childCount(); i++) {
colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue());
delete colMap[i];
}
- delete colMap;
+ delete [] colMap;
}
void ListEdit::fixTypes()
{
int i;
ColumnDef *pDef;
for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) {
if( pDef->hasFlag(ColumnDef::typeUnique) )
fixTypes(i);
}
_typeTable->sort();
}
// --- storeInList ------------------------------------------------------------
void ListEdit::storeInList(QStringList &lst)
{
// delete old content
lst.clear();
// add new one
fixTypes();
QListViewItem *itm=_typeTable->firstChild();
while( itm ) {
int i=0;
QString sAdd;
ColumnDef *pDef;
for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) {
if( i>=1 ) sAdd+=";";
sAdd += itm->text(i);
}
lst.append( sAdd );
itm=itm->nextSibling();
}
}
// --- slotClicked ------------------------------------------------------------
void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col)
{
(void)pnt; // get rid of unused warning;
// save values
_currentItem=itm;
_currentColumn=col;
if( itm==NULL ) {
_typeEdit->setText("");
_stack->raiseWidget(_typeEdit);
return;
}
// display value
if( _currentColumn<0 ) _currentColumn=0;
ColumnDef *pDef=this->at(_currentColumn);
if( pDef->isType(ColumnDef::typeString) ) {
_typeEdit->setText( _currentItem->text(_currentColumn) );
_stack->raiseWidget(_typeEdit);
} else if( pDef->isType(ColumnDef::typeList) ){
_box->clear();
_box->insertStringList( pDef->getValueList() );
QStringList::Iterator itr;
int i=0;
for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) {
if( (*itr)==_currentItem->text(_currentColumn) ) {
_box->setCurrentItem(i);
i=-1;
break;
}
i++;
}
if( i>=0 ) {
_box->insertItem( _currentItem->text(_currentColumn) );
_box->setCurrentItem(i);
}
_stack->raiseWidget(_box);
} else {
odebug << "Unsupported column type for column " << (const char *)pDef->getName() << "" << oendl;
_typeEdit->setText("");
_stack->raiseWidget(_typeEdit);
}
}
// --- addColumnDef -----------------------------------------------------------
void ListEdit::addColumnDef(ColumnDef *pDef)
{
_typeTable->addColumn( pDef->getName() );
_vColumns.append(pDef);
}
// --- addData ----------------------------------------------------------------
void ListEdit::addData(QStringList &lst)
{
// run through list
QStringList::Iterator itr;
for(itr=lst.begin(); itr!=lst.end(); itr++) {
diff --git a/noncore/apps/opie-console/TEScreen.cpp b/noncore/apps/opie-console/TEScreen.cpp
index 2675d31..8e91532 100644
--- a/noncore/apps/opie-console/TEScreen.cpp
+++ b/noncore/apps/opie-console/TEScreen.cpp
@@ -1022,187 +1022,187 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks)
s++;
}
if (s <= sel_BR)
{
// The line break handling
// It's different from the screen
// image case!
if (eol % columns == 0)
{
// That's either a completely filled
// line or an empty line
if (eol == 0)
{
m[d++] = '\n';
}
else
{
// We have a full line.
// FIXME: How can we handle newlines
// at this position?!
}
}
else if ((eol + 1) % columns == 0)
{
// FIXME: We don't know if this was a
// space at the last position or a
// short line!!
m[d++] = ' ';
}
else
{
// We have a short line here. Put a
// newline or a space into the
// buffer.
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
hY++;
hX = 0;
s = hY * columns;
}
else
{ // or from screen image.
eol = (s / columns + 1) * columns - 1;
if (eol < sel_BR)
{
while ((eol > s) &&
isspace(image[eol - hist_BR].c))
{
eol--;
}
}
else
{
eol = sel_BR;
}
while (s <= eol)
{
m[d++] = image[s++ - hist_BR].c;
}
if (eol < sel_BR)
{
// eol processing see below ...
if ((eol + 1) % columns == 0)
{
if (image[eol - hist_BR].c == ' ')
{
m[d++] = ' ';
}
}
else
{
m[d++] = ((preserve_line_breaks ||
((eol % columns) == 0)) ?
'\n' : ' ');
}
}
s = (eol / columns + 1) * columns;
}
}
QChar* qc = new QChar[d];
for (int i = 0; i < d; i++)
{
qc[i] = m[i];
}
QString res(qc, d);
- delete m;
- delete qc;
+ delete [] m;
+ delete [] qc;
return res;
}
QString TEScreen::getHistory() {
sel_begin = 0;
sel_BR = sel_begin;
sel_TL = sel_begin;
setSelExtentXY(columns-1,lines-1);
QString tmp=getSelText(true);
while (tmp.at(tmp.length()-2).unicode()==10 && tmp.at(tmp.length()-1).unicode()==10)
tmp.truncate(tmp.length()-1);
return tmp;
}
/* above ... end of line processing for selection -- psilva
cases:
1) (eol+1)%columns == 0 --> the whole line is filled.
If the last char is a space, insert (preserve) space. otherwise
leave the text alone, so that words that are broken by linewrap
are preserved.
FIXME:
* this suppresses \n for command output that is
sized to the exact column width of the screen.
2) eol%columns == 0 --> blank line.
insert a \n unconditionally.
Do it either you would because you are in preserve_line_break mode,
or because it's an ASCII paragraph delimiter, so even when
not preserving line_breaks, you want to preserve paragraph breaks.
3) else --> partially filled line
insert a \n in preserve line break mode, else a space
The space prevents concatenation of the last word of one
line with the first of the next.
*/
void TEScreen::addHistLine()
{
assert(hasScroll() || histCursor == 0);
// add to hist buffer
// we have to take care about scrolling, too...
if (hasScroll())
{ ca dft;
int end = columns-1;
while (end >= 0 && image[end] == dft)
end -= 1;
hist.addCells(image,end+1);
hist.addLine();
// adjust history cursor
histCursor += (hist.getLines()-1 == histCursor);
}
if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround
}
void TEScreen::setHistCursor(int cursor)
{
histCursor = cursor; //FIXME:rangecheck
}
int TEScreen::getHistCursor()
{
return histCursor;
}
int TEScreen::getHistLines()
{
return hist.getLines();
}
void TEScreen::setScroll(bool on)
{
histCursor = 0;
clearSelection();
hist.setScroll(on);
}
bool TEScreen::hasScroll()
{
return hist.hasScroll();
}
diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp
index 338bc30..51fe707 100644
--- a/noncore/apps/opie-sheet/Excel.cpp
+++ b/noncore/apps/opie-sheet/Excel.cpp
@@ -245,193 +245,193 @@ void ExcelBook::SeekPosition(int pos)
{
if(!feof(File))
{
Position=pos;
//printf("SeekPosition:Pos:%d\r\n",Position);
fseek(File,pos,SEEK_SET);
};
};
void ExcelBook::SeekSkip(int pos)
{
if(!feof(File))
{
Position=Position+pos;
//printf("SeekSkip:Pos:%d\r\n",Position);
fseek(File, Position, SEEK_SET);
};
};
int ExcelBook::FileEOF(void)
{
if(File!=NULL) return(feof(File)); else return 0;
//EOF is defined in stdlib as -1
};
int ExcelBook::Get2Bytes(void)
{
int i1,i2;
i1=0; i2=0;
if (!feof(File))
{
i1=fgetc(File);
Position++;
};
if (!feof(File))
{
i2=fgetc(File);
Position++;
};
return Integer2Byte(i1,i2);
};
char* ExcelBook::Read(int pos, int length)
{
int i;
char *data;
data= new char[length];
SeekPosition(pos);
for(i=0; i<length; i++)
{
if(!feof(File)) data[i]=fgetc(File);
};
Position= Position+length;
return data;
};
QString ExcelBook::ReadUnicodeChar(int pos, int length)
{
int i;
QString data;
int i1=' ',i2=' ',ii;
SeekPosition(pos);
for(i=0; i<length; i++)
{
if(!feof(File)) i1=fgetc(File);
if(!feof(File)) i2=fgetc(File);
ii=Integer2Byte(i1,i2);
data.append(ii);
Position+=2;
};
return data;
};
QString* ExcelBook::GetString(int num)
{
if(num>=0 && num<(int)SharedStrings.count())
{
return SharedStrings[num];
};
return new QString("");
};
int ExcelBook::SeekBOF(void)
{
int opcode,version,streamtype,length,ret=0;
char *data;
while(!feof(File))
{
opcode=Get2Bytes();
if(opcode==XL_BOF)
{
length=Get2Bytes();
data=Read(Position,length);
version=Integer2Byte(data[0], data[1]);
streamtype=Integer2Byte(data[2], data[3]);
printf("SEEKBOF:opcode=XLBOF, %d ,version %d\r\n",Position,version);
- delete data; data=NULL;
+ delete [] data; data=NULL;
if (version==BIFF8) ret=8;
else if(version==BIFF7) ret=7;
printf("SEEKBOF:versionBIFF%d\r\n",ret);
if(streamtype==WBKGLOBAL) return ret *2;
else if(streamtype==WRKSHEET) return ret *1;
return 1;
};
};
return 0;
};
ExcelBREC* ExcelBook::GetBREC(void)
{
ExcelBREC* rec;
rec= new ExcelBREC;
if(FileEOF()) return NULL;
rec->data=NULL;
rec->code=Get2Bytes();
rec->length=Get2Bytes();
rec->position=Position;
SeekSkip(rec->length);
return rec;
};
ExcelBREC* ExcelBook::PeekBREC(void)
{
int oldpos;
ExcelBREC* NextRec;
oldpos=Position;
NextRec=GetBREC();
SeekPosition(oldpos);
return NextRec;
};
char* ExcelBook::GetDataOfBREC(ExcelBREC* record)
{
if(record->data==NULL)
{
ConvertCharToArray(record,Read(record->position,record->length),record->length);
};
return record->data;//new?
};
void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length)
{
record->data=new char[length];
for(int w1=0;w1<=length-1;w1++)
record->data[w1]=chars[w1];
};
bool ExcelSheet::InitCells()
{
int r;
Cells.resize(rows * cols + cols+1);
if(Cells.count()==0) return false;
for(r=0;r < Cells.count();r++)
{
Cells[r]=NULL;
};
return true;
};
void ExcelSheet::Set(int row, int col, ExcelCell* cell)
{
if(cell!=NULL&&(row*cols+col)<Cells.count())
{
Cells[row*cols+col]=cell;
};
};
ExcelCell* ExcelSheet::Get(int row, int col)
{
ExcelCell* cell;
cell=Cells[row*cols+col];
if(cell==NULL) return NULL;
return cell;
};
int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record)
{
char* data=NULL;
switch (record->code)
{
case XL_DIMENSION:
data = GetDataOfBREC(record);
if (record->length == 10)
{
sheet->rows = Integer2Byte(data[2], data[3]);
sheet->cols = Integer2Byte(data[6], data[7]);
}
else
{
sheet->rows = Integer4Byte(data[4], data[5], data[6], data[7]);
sheet->cols = Integer2Byte(data[10], data[11]);
}
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index 6dc4fd2..a70f3aa 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -2126,254 +2126,254 @@ void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, i
attr = nextAttr;
a = &m_attribs[attr & taAttrMask];
if (attr & taSelected) paint.setPen(a->selCol);
else paint.setPen(a->col);
if (a->bold && a->italic)
paint.setFont(myFontBI);
else if (a->bold)
paint.setFont(myFontBold);
else if (a->italic)
paint.setFont(myFontItalic);
else
paint.setFont(myFont);
}
// paint.drawLine(x - xStart, y -2, x - xStart, y);
// paint.drawLine(x - xStart, y, x - xStart + 2, y);
paint.drawPoint(x - xStart, y);
paint.drawPoint(x - xStart +1, y);
paint.drawPoint(x - xStart, y -1);
}
x += m_tabWidth - (x % m_tabWidth);
} else {
nextAttr = textLine->getRawAttr(z);
if (nextAttr != attr) {
if (z > zc) {
QConstString str((QChar *) &s[zc], z - zc /*+1*/);
QString s = str.string();
paint.drawText(x - xStart, y, s);
if (a->bold && a->italic)
x += myFontMetricsBI.width(s);
else if (a->bold)
x += myFontMetricsBold.width(s);
else if (a->italic)
x += myFontMetricsItalic.width(s);
else
x += myFontMetrics.width(s);
zc = z;
}
attr = nextAttr;
a = &m_attribs[attr & taAttrMask];
if (attr & taSelected) paint.setPen(a->selCol);
else paint.setPen(a->col);
if (a->bold && a->italic)
paint.setFont(myFontBI);
else if (a->bold)
paint.setFont(myFontBold);
else if (a->italic)
paint.setFont(myFontItalic);
else
paint.setFont(myFont);
}
}
z++;
}
if (z > zc) {
QConstString str((QChar *) &s[zc], z - zc /*+1*/);
paint.drawText(x - xStart, y, str.string());
}
}
// Applies the search context, and returns whether a match was found. If one is,
// the length of the string matched is also returned.
bool KateDocument::doSearch(SConfig &sc, const QString &searchFor) {
int line, col;
int searchEnd;
int bufLen, tlen;
QChar *t;
TextLine::Ptr textLine;
int pos, newPos;
if (searchFor.isEmpty()) return false;
bufLen = 0;
t = 0L;
line = sc.cursor.y;
col = sc.cursor.x;
if (!(sc.flags & KateView::sfBackward)) {
//forward search
if (sc.flags & KateView::sfSelected) {
if (line < selectStart) {
line = selectStart;
col = 0;
}
searchEnd = selectEnd;
} else searchEnd = lastLine();
while (line <= searchEnd) {
textLine = getTextLine(line);
tlen = textLine->length();
if (tlen > bufLen) {
- delete t;
+ delete [] t;
bufLen = (tlen + 255) & (~255);
t = new QChar[bufLen];
}
memcpy(t, textLine->getText(), tlen*sizeof(QChar));
if (sc.flags & KateView::sfSelected) {
pos = 0;
do {
pos = textLine->findSelected(pos);
newPos = textLine->findUnselected(pos);
memset(&t[pos], 0, (newPos - pos)*sizeof(QChar));
pos = newPos;
} while (pos < tlen);
}
QString text(t, tlen);
if (sc.flags & KateView::sfWholeWords) {
// Until the end of the line...
while (col < tlen) {
// ...find the next match.
col = sc.search(text, col);
if (col != -1) {
// Is the match delimited correctly?
if (((col == 0) || (!m_highlight->isInWord(t[col]))) &&
((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) {
goto found;
}
else {
// Start again from the next character.
col++;
}
}
else {
// No match.
break;
}
}
}
else {
// Non-whole-word search.
col = sc.search(text, col);
if (col != -1)
goto found;
}
col = 0;
line++;
}
} else {
// backward search
if (sc.flags & KateView::sfSelected) {
if (line > selectEnd) {
line = selectEnd;
col = -1;
}
searchEnd = selectStart;
} else searchEnd = 0;
while (line >= searchEnd) {
textLine = getTextLine(line);
tlen = textLine->length();
if (tlen > bufLen) {
- delete t;
+ delete [] t;
bufLen = (tlen + 255) & (~255);
t = new QChar[bufLen];
}
memcpy(t, textLine->getText(), tlen*sizeof(QChar));
if (sc.flags & KateView::sfSelected) {
pos = 0;
do {
pos = textLine->findSelected(pos);
newPos = textLine->findUnselected(pos);
memset(&t[pos], 0, (newPos - pos)*sizeof(QChar));
pos = newPos;
} while (pos < tlen);
}
if (col < 0 || col > tlen) col = tlen;
QString text(t, tlen);
if (sc.flags & KateView::sfWholeWords) {
// Until the beginning of the line...
while (col >= 0) {
// ...find the next match.
col = sc.search(text, col);
if (col != -1) {
// Is the match delimited correctly?
if (((col == 0) || (!m_highlight->isInWord(t[col]))) &&
((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) {
goto found;
}
else {
// Start again from the previous character.
col--;
}
}
else {
// No match.
break;
}
}
}
else {
// Non-whole-word search.
col = sc.search(text, col);
if (col != -1)
goto found;
}
col = -1;
line--;
}
}
sc.flags |= KateView::sfWrapped;
return false;
found:
if (sc.flags & KateView::sfWrapped) {
if ((line > sc.startCursor.y || (line == sc.startCursor.y && col >= sc.startCursor.x))
^ ((sc.flags & KateView::sfBackward) != 0)) return false;
}
sc.cursor.x = col;
sc.cursor.y = line;
return true;
}
void KateDocument::tagLine(int line) {
if (tagStart > line) tagStart = line;
if (tagEnd < line) tagEnd = line;
}
void KateDocument::insLine(int line) {
KateView *view;
if (selectStart >= line) selectStart++;
if (selectEnd >= line) selectEnd++;
if (tagStart >= line) tagStart++;
if (tagEnd >= line) tagEnd++;
newDocGeometry = true;
for (view = views.first(); view != 0L; view = views.next() ) {
view->insLine(line);
}
}
void KateDocument::delLine(int line) {
KateView *view;
if (selectStart >= line && selectStart > 0) selectStart--;
if (selectEnd >= line) selectEnd--;
if (tagStart >= line && tagStart > 0) tagStart--;
if (tagEnd >= line) tagEnd--;
newDocGeometry = true;
for (view = views.first(); view != 0L; view = views.next() ) {
view->delLine(line);
}
}
void KateDocument::optimizeSelection() {
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
index 837fcc5..27ae101 100644
--- a/noncore/comm/keypebble/krfbdecoder.cpp
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -132,193 +132,193 @@ KRFBDecoder::~KRFBDecoder()
void KRFBDecoder::start()
{
sendClientInit();
}
void KRFBDecoder::sendClientInit()
{
con->write( &( con->options()->shared ), 1 );
// Wait for server init
owarn << "Waiting for server init" << oendl;
static QString statusMsg = tr( "Waiting for server initialization..." );
emit status( statusMsg );
currentState = AwaitingServerInit;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) );
con->waitForData( ServerInitLength );
}
void KRFBDecoder::gotServerInit()
{
owarn << "Got server init" << oendl;
disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) );
if ( info )
delete info;
info = new KRFBServerInfo;
CHECK_PTR( info );
con->read( &(info->width), 2 );
info->width = Swap16IfLE( info->width );
con->read( &info->height, 2 );
info->height = Swap16IfLE( info->height );
con->read( &(info->bpp), 1 );
con->read( &(info->depth), 1 );
con->read( &(info->bigEndian), 1 );
con->read( &(info->trueColor), 1 );
con->read( &(info->redMax), 2 );
info->redMax = Swap16IfLE( info->redMax );
con->read( &(info->greenMax), 2 );
info->greenMax = Swap16IfLE( info->greenMax );
con->read( &(info->blueMax), 2 );
info->blueMax = Swap16IfLE( info->blueMax );
con->read( &(info->redShift), 1 );
con->read( &(info->greenShift), 1 );
con->read( &(info->blueShift), 1 );
con->read( info->padding, 3 );
con->read( &(info->nameLength), 4 );
info->nameLength = Swap32IfLE( info->nameLength );
owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl;
owarn << "Bpp = " << info->bpp << ", Depth = " << info->depth << ", Big = " << info->bigEndian
<< ", True = " << info->trueColor << oendl;
owarn << "RedMax = " << info->redMax << ", GreenMax = " << info->greenMax << ", BlueMax = " << info->blueMax << oendl;
owarn << "RedShift = " << info->redShift << ", GreenShift = " << info->greenShift
<< ", BlueShift = " << info-> blueShift << oendl;
buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor);
// Wait for desktop name
owarn << "Waiting for desktop name" << oendl;
static QString statusMsg = tr( "Waiting for desktop name..." );
emit status( statusMsg );
currentState = AwaitingDesktopName;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) );
con->waitForData( info->nameLength );
}
void KRFBDecoder::gotDesktopName()
{
assert( info );
assert( currentState == AwaitingDesktopName );
owarn << "Got desktop name" << oendl;
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotDesktopName() ) );
char *buf = new char[ info->nameLength + 1 ];
CHECK_PTR( buf );
con->read( buf, info->nameLength );
buf[ info->nameLength ] = '\0';
info->name = buf;
owarn << "Desktop: " << info->name.latin1() << "" << oendl;
- delete buf;
+ delete [] buf;
// Get the format we'll really use and tell the server
decidePixelFormat();
sendPixelFormat();
sendAllowedEncodings();
currentState = Idle;
QString msg;
msg = tr( "Connected to %1" );
msg = msg.arg( info->name );
emit status( msg );
sendUpdateRequest( false );
}
void KRFBDecoder::decidePixelFormat()
{
assert( info );
if ( format )
delete format;
format = new KRFBPixelFormat;
CHECK_PTR( format );
// What depth do we want?
//
// We'll use the minimum of the remote and local depths, UNLESS an
// eight bit session has been specifically requested by the user.
int screenDepth = QPixmap::defaultDepth();
int bestDepth = ( screenDepth > info->depth ) ? info->depth : screenDepth;
int chosenDepth;
if ( con->options()->colors256 )
chosenDepth = 8;
else
chosenDepth = bestDepth;
owarn << "Screen depth=" << screenDepth << ", server depth=" << info->depth
<< ", best depth=" << bestDepth << "eight bit " << con->options()->colors256
<< ", chosenDepth=" << chosenDepth << oendl;
format->depth = chosenDepth;
// If we're using the servers native depth
if ( chosenDepth == info->depth ) {
// Use the servers native format
format->bpp = info->bpp;
// format->bigEndian = info->bigEndian;
format->bigEndian = true;
format->trueColor = info->trueColor;
format->redMax = info->redMax;
format->greenMax = info->greenMax;
format->blueMax = info->blueMax;
format->redShift = info->redShift;
format->greenShift = info->greenShift;
format->blueShift = info->blueShift;
}
else {
if ( chosenDepth == 8 ) {
format->bpp = 8;
format->bigEndian = true;
format->trueColor = true;
format->redMax = 7;
format->greenMax = 7;
format->blueMax = 3;
format->redShift = 0;
format->greenShift = 3;
format->blueShift = 6;
}
}
format->redMax = Swap16IfLE( format->redMax );
format->greenMax = Swap16IfLE( format->greenMax );
format->blueMax = Swap16IfLE( format->blueMax );
}
void KRFBDecoder::sendPixelFormat()
{
static char padding[3];
con->write( &SetPixelFormatId, 1 );
con->write( padding, 3 );
con->write( &(format->bpp), 1 );
con->write( &(format->depth), 1 );
con->write( &(format->bigEndian), 1 );
con->write( &(format->trueColor), 1 );
con->write( &(format->redMax), 2 );
con->write( &(format->greenMax), 2 );
con->write( &(format->blueMax), 2 );
con->write( &(format->redShift), 1 );
con->write( &(format->greenShift), 1 );
con->write( &(format->blueShift), 1 );
con->write( format->padding, 3 ); // Padding
}
@@ -442,386 +442,386 @@ void KRFBDecoder::gotRectHeader()
//
// Each encoding needs to be handled differently. Some require
// waiting for more data, but others like a copyrect do not.
// Our constants have already been byte swapped, so we use
// the remote value as is.
//
if ( encoding == RawEncoding ) {
// owarn << "Raw encoding" << oendl;
handleRawRect();
}
else if ( encoding == CopyRectEncoding ) {
// owarn << "CopyRect encoding" << oendl;
handleCopyRect();
}
else if ( encoding == RreEncoding ) {
owarn << "RRE encoding" << oendl;
handleRRERect();
}
else if ( encoding == CorreEncoding ) {
owarn << "CoRRE encoding" << oendl;
handleCoRRERect();
}
else if ( encoding == HexTileEncoding ) {
owarn << "HexTile encoding" << oendl;
handleHexTileRect();
}
else {
int msg = Swap32IfLE( encoding );
QString protocolError = tr( "Protocol Error: An unknown encoding was "
"used by the server %1" ).arg( msg );
currentState = Error;
owarn << "Unknown encoding, " << msg << "" << oendl;
emit error( protocolError );
return;
}
}
//
// Raw Encoding
//
void KRFBDecoder::handleRawRect()
{
// We need something a bit cleverer here to handle large
// rectanges nicely. The chunking should be based on the
// overall size (but has to be in complete lines).
// owarn << "Handling a raw rect chunk" << oendl;
// CARD32 lineCount = w * format->bpp / 8;
if ( h > RectChunkSize ) {
// if ( con->sock->size() / lineCount ) {
// getRawRectChunk( con->sock->size() / lineCount );
// }
// else {
getRawRectChunk( RectChunkSize );
// }
}
else {
getRawRectChunk( h );
}
}
void KRFBDecoder::getRawRectChunk( int lines )
{
this->lines = lines;
CARD32 count = lines * w * format->bpp / 8;
// Wait for server init
// owarn << "Waiting for raw rect chunk, " << count << "" << oendl;
currentState = AwaitingRawRectChunk;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) );
con->waitForData( count );
}
void KRFBDecoder::gotRawRectChunk()
{
assert( currentState == AwaitingRawRectChunk );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotRawRectChunk() ) );
// owarn << "Got raw rect chunk" << oendl;
//
// Read the rect data and copy it to the buffer.
//
// TODO: Replace this!
int count = lines * w * format->bpp / 8;
char *hack = new char[ count ];
con->read( hack, count );
buf->drawRawRectChunk( hack, x, y, w, lines );
- delete hack;
+ delete [] hack;
// /TODO:
h = h - lines;
y = y + lines;
if ( h > 0 ) {
handleRawRect();
}
else {
noRects--;
// owarn << "There are " << noRects << " rects left" << oendl;
if ( noRects ) {
currentState = AwaitingRectHeader;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
con->waitForData( RectHeaderLength );
}
else {
// we are now ready for the next update - no need to wait for the timer
currentState = Idle;
sendUpdateRequest (1);
}
}
}
//
// Copy Rectangle Encoding
//
void KRFBDecoder::handleCopyRect()
{
currentState = AwaitingCopyRectPos;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotCopyRectPos() ) );
con->waitForData( CopyRectPosLength );
}
void KRFBDecoder::gotCopyRectPos()
{
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotCopyRectPos() ) );
CARD16 srcX;
CARD16 srcY;
con->read( &srcX, 2 );
con->read( &srcY, 2 );
srcX = Swap16IfLE( srcX );
srcY = Swap16IfLE( srcY );
buf->copyRect( srcX, srcY, x, y, w, h );
noRects--;
// owarn << "There are " << noRects << " rects left" << oendl;
if ( noRects ) {
currentState = AwaitingRectHeader;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
con->waitForData( RectHeaderLength );
}
else
currentState = Idle;
}
void KRFBDecoder::handleRRERect()
{
owarn << "RRE not implemented" << oendl;
}
void KRFBDecoder::handleCoRRERect()
{
owarn << "CoRRE not implemented" << oendl;
}
void KRFBDecoder::handleHexTileRect()
{
owarn << "HexTile not implemented" << oendl;
}
void KRFBDecoder::sendMouseEvent( QMouseEvent *e )
{
// Deal with the buttons
if ( e->type() != QEvent::MouseMove ) {
buttonMask = 0;
if ( e->type() == QEvent::MouseButtonPress ) {
if ( e->button() & LeftButton )
buttonMask |= 0x01;
if ( e->button() & MidButton )
buttonMask |= 0x04;
if ( e->button() & RightButton )
buttonMask |= 0x02;
}
else if ( e->type() == QEvent::MouseButtonRelease ) {
if ( e->button() & LeftButton )
buttonMask &= 0x06;
if ( e->button() & MidButton )
buttonMask |= 0x03;
if ( e->button() & RightButton )
buttonMask |= 0x05;
}
}
// HACK: Scaling
CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor );
CARD16 y = Swap16IfLE( e->y() * con->options()->scaleFactor );
con->write( &PointerEventId, 1 );
con->write( &buttonMask, 1 );
con->write( &x, 2 );
con->write( &y, 2 );
}
void KRFBDecoder::sendCutEvent( const QString &unicode )
{
//
// Warning: There is a bug in the RFB protocol because there is no way to find
// out the codepage in use on the remote machine. This could be fixed by requiring
// the remote server to use utf8 etc. but for now we have to assume they're the
// same. I've reported this problem to the ORL guys, but they apparantly have no
// immediate plans to fix the issue. :-( (rich)
//
CARD8 padding[3];
QCString text = unicode.local8Bit();
CARD32 length = text.length();
length = Swap32IfLE( length );
con->write( &ClientCutTextId, 1 );
con->write( &padding, 3 );
con->write( &length, 4 );
con->write( text.data(), length );
}
void KRFBDecoder::gotServerCut()
{
owarn << "Got server cut" << oendl;
currentState = AwaitingServerCutLength;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) );
con->waitForData( ServerCutLenLength );
}
void KRFBDecoder::gotServerCutLength()
{
assert( currentState = AwaitingServerCutLength );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotServerCutLength() ) );
CARD8 padding[3];
con->read( padding, 3 );
con->read( &serverCutTextLen, 4 );
serverCutTextLen = Swap32IfLE( serverCutTextLen );
currentState = AwaitingServerCutText;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutText() ) );
con->waitForData( serverCutTextLen );
}
void KRFBDecoder::gotServerCutText()
{
assert( currentState = AwaitingServerCutText );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotServerCutText() ) );
//
// Warning: There is a bug in the RFB protocol because there is no way to find
// out the codepage in use on the remote machine. This could be fixed by requiring
// the remote server to use utf8 etc. but for now we have to assume they're the
// same. I've reported this problem to the ORL guys, but they apparantly have no
// immediate plans to fix the issue. :-( (rich)
//
char *cutbuf = new char[ serverCutTextLen + 1 ];
CHECK_PTR( cutbuf );
con->read( cutbuf, serverCutTextLen );
cutbuf[ serverCutTextLen ] = '\0';
/* For some reason QApplication::clipboard()->setText() segfaults when called
* from within keypebble's mass of signals and slots
owarn << "Server cut: " << cutbuf << "" << oendl;
QString cutText( cutbuf ); // DANGER!!
qApp->clipboard()->setText( cutText );
*/
- delete cutbuf;
+ delete [] cutbuf;
// Now wait for the update (again)
if ( oldState == AwaitingUpdate ) {
currentState = AwaitingUpdate;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
con->waitForData( UpdateHeaderLength );
}
else if ( oldState == Idle ) {
currentState = Idle;
}
else {
owarn << "Async handled in weird state" << oendl;
currentState = oldState;
};
}
void KRFBDecoder::gotBell()
{
owarn << "Got server bell" << oendl;
buf->soundBell();
// Now wait for the update (again)
if ( oldState == AwaitingUpdate ) {
currentState = AwaitingUpdate;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
con->waitForData( UpdateHeaderLength );
}
else if ( oldState == Idle ) {
currentState = Idle;
}
else {
owarn << "Async handled in weird state" << oendl;
currentState = oldState;
};
}
void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event )
{
int key;
key = toKeySym( event );
if ( key ) {
key = Swap32IfLE( key );
CARD8 mask = true;
CARD16 padding = 0;
con->write( &KeyEventId, 1 );
con->write( &mask, 1 );
con->write( &padding, 2 );
con->write( &key, 4 );
}
}
void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event )
{
int key;
key = toKeySym( event );
if ( key ) {
key = Swap32IfLE( key );
CARD8 mask = false;
CARD16 padding = 0;
con->write( &KeyEventId, 1 );
con->write( &mask, 1 );
con->write( &padding, 2 );
con->write( &key, 4 );
}
}
//
// The RFB protocol spec says 'For most ordinary keys, the 'keysym'
// is the same as the corresponding ASCII value.', but doesn't
// elaborate what the most ordinary keys are. The spec also lists
// a set (possibly subset, it's unspecified) of mappings for
// "other common keys" (backspace, tab, return, escape, etc).
//
int KRFBDecoder::toKeySym( QKeyEvent *k )
{
//
// Try and map these "other common keys" first.
//
if ((k->key() >= Qt::Key_Escape) && (k->key() <= Qt::Key_F12)) {
for(int i = 0; keyMap[i].keycode != 0; i++) {
if (k->key() == keyMap[i].keycode) {
return keyMap[i].keysym;
}
}
}
//
// If these keys aren't matched, return the ascii code and let the
// server figure it out. We don't return k->key(), as the data in
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp
index a6c92a0..516dc93 100644
--- a/noncore/games/sfcave/sfcave.cpp
+++ b/noncore/games/sfcave/sfcave.cpp
@@ -905,193 +905,193 @@ void SFCave :: keyReleaseEvent( QKeyEvent *e )
}
}
void SFCave :: saveScore()
{
#ifdef QWS
Config cfg( "sfcave" );
cfg.setGroup( "settings" );
QString key = "highScore_";
cfg.writeEntry( key + gameTypes[currentGameType] + "_" + dificultyOption[currentGameDifficulty], highestScore[currentGameType][currentGameDifficulty] );
key += CURRENT_GAME_TYPE;
cfg.writeEntry( key, highestScore[currentGameType] );
#endif
}
void SFCave :: saveReplay()
{
FILE *out;
out = fopen( QFile::encodeName(replayFile).data(), "w" );
if ( !out )
{
printf( "Couldn't write to %s\n", QFile::encodeName(replayFile).data() );
return;
}
// Build up string of values
// Format is:: <landscape seed> <game type> <difficulty> <framenr> <framenr>.......
QString val;
val.sprintf( "%d %d %d ", currentSeed, currentGameType, currentGameDifficulty );
QListIterator<int> it( replayList );
while( it.current() )
{
QString tmp;
tmp.sprintf( "%d ", (*it.current()) );
val += tmp;
++it;
}
val += "\n";
QString line;
line.sprintf( "%d\n", val.length() );
fwrite( (const char *)line, 1, line.length(), out );
fwrite( (const char *)val, 1, val.length(), out );
fclose( out );
printf( "Replay saved to %s\n", QFile::encodeName(replayFile).data() );
}
void SFCave :: loadReplay()
{
FILE *in = fopen( QFile::encodeName(replayFile).data() , "r" );
if ( in == 0 )
{
printf( "Couldn't load replay file!\n" );
return;
}
// Read next line - contains the size of the options
char line[10+1];
fgets( line, 10, in );
int length = -1;
sscanf( line, "%d", &length );
char *data = new char[length+1];
fread( data, 1, length, in );
// printf( "data - %s", data );
QString sep = " ";
QStringList list = QStringList::split( sep, QString( data ) );
// print it out
QStringList::Iterator it = list.begin();
currentSeed = (*it).toInt();
++it;
currentGameType = (*it).toInt();
++it;
currentGameDifficulty = (*it).toInt();
++it;
replayList.clear();
for ( ; it != list.end(); ++it )
{
int v = (*it).toInt();
replayList.append( new int( v ) );
}
- delete data;
+ delete [] data;
fclose( in );
printf( "Replay loaded from %s\n", QFile::encodeName(replayFile).data() );
}
//--------------- MENU CODE ---------------------
void SFCave :: handleMenuKeys( QKeyEvent *e )
{
switch( e->key() )
{
case Qt::Key_Down:
currentMenuOption[currentMenuNr] ++;
if ( menuOptions[currentMenuNr][currentMenuOption[currentMenuNr]] == "" )
currentMenuOption[currentMenuNr] = 0;
break;
case Qt::Key_Up:
currentMenuOption[currentMenuNr] --;
if ( currentMenuOption[currentMenuNr] < 0 )
currentMenuOption[currentMenuNr] = nrMenuOptions[currentMenuNr]-1;
break;
case Qt::Key_Left:
if ( currentMenuNr == MENU_OPTIONS_MENU )
{
if ( currentMenuOption[currentMenuNr] == MENU_GAME_TYPE )
{
currentGameType --;
if ( currentGameType < 0 )
currentGameType = NR_GAME_TYPES - 1;
}
else if ( currentMenuOption[currentMenuNr] == MENU_GAME_DIFFICULTY )
{
currentGameDifficulty --;
if ( currentGameDifficulty < 0 )
currentGameDifficulty = NR_GAME_DIFFICULTIES - 1;
}
}
break;
case Qt::Key_Right:
if ( currentMenuNr == MENU_OPTIONS_MENU )
{
if ( currentMenuOption[currentMenuNr] == MENU_GAME_TYPE )
{
currentGameType ++;
if ( currentGameType == NR_GAME_TYPES )
currentGameType = 0;
}
else if ( currentMenuOption[currentMenuNr] == MENU_GAME_DIFFICULTY )
{
currentGameDifficulty ++;
if ( currentGameDifficulty == NR_GAME_DIFFICULTIES )
currentGameDifficulty = 0;
}
}
break;
case Qt::Key_Space:
case Qt::Key_Return:
case Qt::Key_Enter:
dealWithMenuSelection();
break;
}
}
void SFCave :: displayMenu()
{
offscreen->fill( Qt::black );
QPainter p( offscreen );
p.setPen( Qt::white );
QFont f( "Helvetica", 16 );
p.setFont( f );
QFontMetrics fm = p.fontMetrics();
QString text = "SFCave";
p.drawText( (sWidth/2) - (fm.width( text )/2), 60, text );
text = "Written by Andy Qua";
p.drawText( (sWidth/2) - (fm.width( text )/2), 85, text );
// Draw options
int pos = 140;
for ( int i = 0 ; menuOptions[currentMenuNr][i] != "" ; ++i, pos += 25 )
{
if ( currentMenuOption[currentMenuNr] == i )
p.setPen( Qt::yellow );
else
p.setPen( Qt::white );
QString text;
if ( menuOptions[currentMenuNr][i].find( "%s" ) != -1 )
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp
index 7ffa1d6..0886e69 100644
--- a/noncore/settings/aqpkg/settingsimpl.cpp
+++ b/noncore/settings/aqpkg/settingsimpl.cpp
@@ -254,193 +254,193 @@ QWidget *SettingsImpl :: initProxyTab()
QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), tr( "Update" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) );
layout->addMultiCellWidget( btn, 4, 4, 0, 1 );
return control;
}
void SettingsImpl :: setupData()
{
// add servers
QString serverName;
QListIterator<Server> it( dataMgr->getServerList() );
for ( ; it.current(); ++it )
{
serverName = it.current()->getServerName();
if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS )
continue;
servers->insertItem( serverName );
}
// add destinations
QListIterator<Destination> it2( dataMgr->getDestinationList() );
for ( ; it2.current(); ++it2 )
destinations->insertItem( it2.current()->getDestinationName() );
// setup proxy tab
txtHttpProxy->setText( dataMgr->getHttpProxy() );
txtFtpProxy->setText( dataMgr->getFtpProxy() );
txtUsername->setText( dataMgr->getProxyUsername() );
txtPassword->setText( dataMgr->getProxyPassword() );
chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() );
chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() );
}
//------------------ Servers tab ----------------------
void SettingsImpl :: editServer( int sel )
{
currentSelectedServer = sel;
Server *s = dataMgr->getServer( servers->currentText() );
if ( s )
{
serverName = s->getServerName();
servername->setText( s->getServerName() );
serverurl->setText( s->getServerUrl() );
active->setChecked( s->isServerActive() );
}
else
{
serverName = "";
servername->setText( "" );
serverurl->setText( "" );
active->setChecked( false );
}
}
void SettingsImpl :: newServer()
{
newserver = true;
servername->setText( "" );
serverurl->setText( "" );
servername->setFocus();
active->setChecked( true );
}
void SettingsImpl :: removeServer()
{
changed = true;
Server *s = dataMgr->getServer( servers->currentText() );
if ( s )
{
dataMgr->getServerList().removeRef( s );
servers->removeItem( currentSelectedServer );
}
}
void SettingsImpl :: changeServerDetails()
{
changed = true;
QString newName = servername->text();
// Convert any spaces to underscores
char *tmpStr = new char[newName.length() + 1];
for ( unsigned int i = 0 ; i < newName.length() ; ++i )
{
if ( newName[i] == ' ' )
tmpStr[i] = '_';
else
tmpStr[i] = newName[i].latin1();
}
tmpStr[newName.length()] = '\0';
newName = tmpStr;
- delete tmpStr;
+ delete [] tmpStr;
if ( !newserver )
{
Server *s = dataMgr->getServer( servers->currentText() );
if ( s )
{
// Update url
s->setServerUrl( serverurl->text() );
s->setActive( active->isChecked() );
// Check if server name has changed, if it has then we need to replace the key in the map
if ( serverName != newName )
{
// Update server name
s->setServerName( newName );
}
// Update list box
servers->changeItem( newName, currentSelectedServer );
}
}
else
{
Server s( newName, serverurl->text() );
dataMgr->getServerList().append( new Server( newName, serverurl->text() ) );
dataMgr->getServerList().last()->setActive( active->isChecked() );
servers->insertItem( newName );
servers->setCurrentItem( servers->count() );
newserver = false;
}
}
//------------------ Destinations tab ----------------------
void SettingsImpl :: editDestination( int sel )
{
currentSelectedDestination = sel;
Destination *d = dataMgr->getDestination( destinations->currentText() );
if ( d )
{
destinationName = d->getDestinationName();
destinationname->setText( d->getDestinationName() );
destinationurl->setText( d->getDestinationPath() );
linkToRoot->setChecked( d->linkToRoot() );
}
else
{
destinationName = "";
destinationname->setText( "" );
destinationurl->setText( "" );
linkToRoot->setChecked( false );
}
}
void SettingsImpl :: newDestination()
{
newdestination = true;
destinationname->setText( "" );
destinationurl->setText( "" );
destinationname->setFocus();
linkToRoot->setChecked( true );
}
void SettingsImpl :: removeDestination()
{
changed = true;
Destination *d = dataMgr->getDestination( destinations->currentText() );
if ( d )
{
dataMgr->getDestinationList().removeRef( d );
destinations->removeItem( currentSelectedDestination );
}
}
void SettingsImpl :: changeDestinationDetails()
{
changed = true;
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "destinations" );
#endif
QString newName = destinationname->text();
if ( !newdestination )
{
Destination *d = dataMgr->getDestination( destinations->currentText() );
if ( d )
{
// Update url
d->setDestinationPath( destinationurl->text() );
d->linkToRoot( linkToRoot->isChecked() );
// Check if server name has changed, if it has then we need to replace the key in the map
if ( destinationName != newName )
{
diff --git a/noncore/settings/aqpkg/version.cpp b/noncore/settings/aqpkg/version.cpp
index 59e6f3f..ce2de7b 100644
--- a/noncore/settings/aqpkg/version.cpp
+++ b/noncore/settings/aqpkg/version.cpp
@@ -1,137 +1,137 @@
/*
* libdpkg - Debian packaging suite library routines
* vercmp.c - comparison of version numbers
*
* Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with dpkg; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <qobject.h>
//# define _(Text) Text
class versionrevision
{
public:
versionrevision()
{
version = 0;
}
~versionrevision()
{
if ( version )
- delete version;
+ delete [] version;
}
void setVersion( const char *str )
{
version = new char[(strlen(str)+1)];
strcpy( version, str );
}
unsigned long epoch;
char *version;
const char *revision;
const char *familiar_revision;
};
static int verrevcmp(const char *val, const char *ref)
{
int vc, rc;
long vl, rl;
const char *vp, *rp;
if (!val) val= "";
if (!ref) ref= "";
for (;;) {
vp= val; while (*vp && !isdigit(*vp)) vp++;
rp= ref; while (*rp && !isdigit(*rp)) rp++;
for (;;) {
vc= val == vp ? 0 : *val++;
rc= ref == rp ? 0 : *ref++;
if (!rc && !vc) break;
if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
if (rc && !isalpha(rc)) rc += 256;
if (vc != rc) return vc - rc;
}
val= vp;
ref= rp;
vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
if (vl != rl) return vl - rl;
if (!*val && !*ref) return 0;
if (!*val) return -1;
if (!*ref) return +1;
}
}
int versioncompare(const struct versionrevision *version,
const struct versionrevision *refversion)
{
int r;
if (version->epoch > refversion->epoch) return 1;
if (version->epoch < refversion->epoch) return -1;
r= verrevcmp(version->version,refversion->version); if (r) return r;
r= verrevcmp(version->revision,refversion->revision); if (r) return r;
return verrevcmp(version->familiar_revision,refversion->familiar_revision);
}
int versionsatisfied3(const struct versionrevision *it,
const struct versionrevision *ref,
const char *op)
{
int r;
r= versioncompare(it,ref);
if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0)
return r <= 0;
if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0)
return r >= 0;
if (strcmp(op, "<<") == 0)
return r < 0;
if (strcmp(op, ">>") == 0)
return r > 0;
if (strcmp(op, "=") == 0)
return r == 0;
// fprintf(stderr, "unknown operator: %s", op);
exit(1);
}
const char *parseversion(struct versionrevision *rversion, const char *string)
{
char *hyphen, *colon, *eepochcolon;
unsigned long epoch;
if ( !*string )
return QObject::tr( "Version string is empty." );
colon= strchr(string,':');
if (colon) {
epoch= strtoul(string,&eepochcolon,10);
if ( colon != eepochcolon )
return QObject::tr( "Epoch in version is not number." );
if ( !*++colon )
return QObject::tr( "Nothing after colon in version number." );
string= colon;
rversion->epoch= epoch;
} else {
rversion->epoch= 0;