summaryrefslogtreecommitdiff
path: root/recipes/zipsc/zipsc-0.4.3/gcc3.patch
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
committerDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
commit709c4d66e0b107ca606941b988bad717c0b45d9b (patch)
tree37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/zipsc/zipsc-0.4.3/gcc3.patch
parentfa6cd5a3b993f16c27de4ff82b42684516d433ba (diff)
rename packages/ to recipes/ per earlier agreement
See links below for more details: http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326 http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816 Signed-off-by: Denys Dmytriyenko <denis@denix.org> Acked-by: Mike Westerhof <mwester@dls.net> Acked-by: Philip Balister <philip@balister.org> Acked-by: Khem Raj <raj.khem@gmail.com> Acked-by: Marcin Juszkiewicz <hrw@openembedded.org> Acked-by: Koen Kooi <koen@openembedded.org> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/zipsc/zipsc-0.4.3/gcc3.patch')
-rw-r--r--recipes/zipsc/zipsc-0.4.3/gcc3.patch961
1 files changed, 961 insertions, 0 deletions
diff --git a/recipes/zipsc/zipsc-0.4.3/gcc3.patch b/recipes/zipsc/zipsc-0.4.3/gcc3.patch
new file mode 100644
index 0000000000..4b2f9a9a6c
--- /dev/null
+++ b/recipes/zipsc/zipsc-0.4.3/gcc3.patch
@@ -0,0 +1,961 @@
+
+#
+# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
+#
+
+--- zipsc_0.4.3/MainWindow.cpp~gcc3 2002-07-06 09:46:25.000000000 +0200
++++ zipsc_0.4.3/MainWindow.cpp 2004-02-20 17:23:03.000000000 +0100
+@@ -1,476 +1,477 @@
+-/**********************************************************************
+-** Copyright (C) 2002 Walter Rawdanik. All rights reserved.
+-**
+-** This file is part of zipsc application for Qtopia Environment.
+-**
+-** Issues:
+-** Due to incomplete design of QueryResult which returns pointer instead of object, it needs to be explicitly
+-** deleted after each use. Extremely error-prone and basically pain-in the ass.
+-** I am still no 100% sure I completely understand Qt layouts. It seems that QComboBox grows to the size of the
+-** widest string in it which causes it to go beyond the edge of the screen on Qtopia small screen.
+-** The only solution I could find was to call setMaximumSize() on each with some hard coded magic number that
+-** looks about right - not a good solution.
+-**
+-**
+-** This file may be distributed and/or modified under the terms of the
+-** GPL license appearing in the file LICENSE included in the
+-** packaging of this file.
+-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+-**
+-**********************************************************************/
+-#include <qpe/qpeapplication.h>
+-#include <qpe/config.h>
+-#include <qpe/fileselector.h>
+-#include "MainWindow.h"
+-#include <stdlib.h>
+-#include <stdio.h>
+-#include <ctype.h>
+-#include <qlayout.h>
+-#include <qframe.h>
+-#include <qlistbox.h>
+-#include <qlabel.h>
+-#include <qcombobox.h>
+-#include <qwidgetstack.h>
+-#include <qlineedit.h>
+-#include <qpushbutton.h>
+-#include <qstringlist.h>
+-#include <qmessagebox.h>
+-#include <qtabbar.h>
+-#include <qtoolbutton.h>
+-#include <qtextbrowser.h>
+-#include <qspinbox.h>
+-#include <qpe/menubutton.h>
+-#include <qpe/qpetoolbar.h>
+-#include "InputDialog.h"
+-#include <qdir.h>
+-#include <qfile.h>
+-
+-AboutDialog::AboutDialog(const QPixmap &icon,const QString &caption, const QString &t,const QString &l,QWidget *parent):QDialog(parent,0,true)
+-{
+- setCaption(caption);
+-
+- if ( parent )
+- {
+- setPalette(parent->palette());
+- }
+-
+- setMinimumSize(220,160);
+- QGridLayout *gl= new QGridLayout(this,2,2,4,2);
+- gl->addRowSpacing ( 0,0);
+- pix=new QLabel(this);
+- pix->setPixmap(icon);
+- gl->addWidget(pix,0,0);
+- title=new QLabel(t,this);
+- gl->addWidget(title,0,1);
+- label=new QLabel(l,this);
+- gl->addMultiCellWidget(label,1,1,0,1);
+-
+-}
+-
+-void AboutDialog::displayAbout(const QPixmap &icon,const QString &caption,const QString &t, const QString &text, QWidget *parent)
+-{
+- AboutDialog *dlg=new AboutDialog(icon,caption,t,text,parent);
+- dlg->exec();
+- delete dlg;
+-}
+-
+-MainWindow::MainWindow( QWidget* parent, const char* name, WFlags f )
+-: QMainWindow( parent, name, f )
+-{
+- setCaption("zIPSC");
+-
+- lColor="#f8f8f8";
+- dColor="#e8e8e8";
+- fColor="#848484";
+- memset(&n, 0, sizeof(n));
+- processType=true;
+-
+- QBoxLayout *topLayout=new QVBoxLayout(this,1);
+-
+-
+- //QFrame *topFrame=new QFrame (this);
+- //topFrame->setMaximumWidth(240);
+-
+- QGridLayout *gl= new QGridLayout(this,3,6,2,2);
+- gl->addColSpacing ( 1,4);
+-
+- topLayout->addLayout(gl);
+- gl->setColStretch(0,0);
+- gl->setColStretch(2,10);
+-
+- QLabel *lb=new QLabel("Address:",this);
+- gl->addWidget(lb,0,0);
+- networkAddress= new QComboBox(true,this);
+- gl->addMultiCellWidget(networkAddress,0,0,2,4);
+- go= new QPushButton("Go",this);
+- gl->addWidget(go,0,5);
+- lb=new QLabel("Type:",this);
+- gl->addWidget(lb,1,0);
+-
+- addressType= new MenuButton ( this);
+- addressType->insertItem("Class A (1.x.x.x - 126.x.x.x)");
+- addressType->insertItem("Class B (128.x.x.x - 191.x.x.x)");
+- addressType->insertItem("Class C (192.x.x.x - 223.x.x.x)");
+- gl->addMultiCellWidget(addressType,1,1,2,5);
+-
+- bitsLabel=new QLabel("Subnet bits:",this);
+- gl->addWidget(bitsLabel,2,0);
+- subnetBits= new QSpinBox(this);
+- gl->addWidget(subnetBits,2,2,AlignLeft);
+-
+- saveB=new QToolButton(this);
+- saveB->setAutoRaise(false);
+- saveB->setPixmap(QPixmap(QPEApplication::qpeDir()+"pics/zipsc/filesave.png_"));
+- gl->addWidget(saveB,2,3);
+- copyB=new QToolButton(this);
+- copyB->setAutoRaise(false);
+- copyB->setPixmap(QPixmap(QPEApplication::qpeDir()+"pics/zipsc/editcopy.png_"));
+- gl->addWidget(copyB,2,4);
+- aboutB=new QToolButton(this);
+- aboutB->setAutoRaise(false);
+- aboutB->setPixmap(QPixmap(QPEApplication::qpeDir()+"pics/zipsc/about.png_"));
+- gl->addWidget(aboutB,2,5);
+-
+- topLayout->addSpacing(4);
+-
+- int i;
+-
+- switcher= new QTabBar(this);
+- switcher->setShape(QTabBar::RoundedAbove);
+-
+- const char *tLabels[]={"General","Subnets/Hosts","Host","CIDR"};
+-
+- for ( i=0;i<T_LAST;i++ )
+- {
+- tabValues[i]=switcher->addTab(new QTab(tLabels[i]));
+- }
+- switcher->setCurrentTab(0);
+- topLayout->addWidget(switcher);
+-
+-
+-
+- pageView=new QWidgetStack(this);
+- for ( i=0;i<T_LAST;i++ )
+- {
+- pages[i]=new QTextBrowser(pageView);
+- pages[i]->setHScrollBarMode(QScrollView::AlwaysOff);
+- pageView->addWidget(pages[i],i);
+- }
+-
+- topLayout->addWidget(pageView,10);
+-
+-
+- initVariables();
+- showPage(GENERAL_VIEW);
+-
+-
+- connect(switcher,SIGNAL(selected(int)),SLOT(showPage(int)));
+- connect(networkAddress->lineEdit(),SIGNAL(returnPressed()),SLOT(goButtonClicked()));
+- connect(go,SIGNAL(clicked()),SLOT(goButtonClicked()));
+- connect(addressType,SIGNAL(selected (int)),SLOT(typeButtonPressed(int)));
+- connect(subnetBits,SIGNAL(valueChanged (int)),SLOT(bitsChanged(int)));
+- connect(saveB,SIGNAL(clicked()),SLOT(saveFile()));
+- connect(copyB,SIGNAL(clicked()),SLOT(copyText()));
+- connect(aboutB,SIGNAL(clicked()),SLOT(displayAbout()));
+-
+-
+-}
+-
+-MainWindow::~MainWindow()
+-{
+- saveVariables();
+-}
+-
+-
+-void MainWindow::goButtonClicked()
+-{
+- QString searchTerm=networkAddress->currentText();
+-
+- if ( searchTerm.isEmpty() )
+- return;
+-
+- if ( ipsc_network_init_parse_text(&n, searchTerm) < 0 )
+- {
+- QMessageBox::warning (this,"zIPSC","Incorrect network address",0);
+- }
+-
+- ipsc_network_init_parse_text(&n,searchTerm);
+- updateAll();
+-
+- // implement history .... if selected text already exists, delete it from the list ... if there are more than 10 items delete last used
+- QListBox *lb=networkAddress->listBox();
+-
+- for ( unsigned int i=0;i<lb->count();i++ )
+- {
+- if ( searchTerm.upper()==lb->text(i).upper() )
+- {
+- lb->removeItem(i);
+- break;
+- }
+- }
+- if ( networkAddress->count()>16 )
+- networkAddress->removeItem(networkAddress->count()-1);
+- networkAddress->insertItem(searchTerm,0);
+-
+- processType=false;
+- subnetBits->setValue(n.subnet_bits);
+- addressType->select((int)(tolower(n.nclass)-'a'));
+- processType=true;
+-
+-}
+-
+-void MainWindow::typeButtonPressed(int i)
+-{
+- if ( processType )
+- {
+- char cl='a'+(int)i;
+-
+- ipsc_network_set_class_info(&n, cl, TRUE);
+- ipsc_network_init(&n);
+- updateAll();
+-
+- QString tmp;
+- tmp.sprintf("%s/%d", denumberize(n.host_addr),ipsc_network_get_prefix_bits(&n));
+- networkAddress->lineEdit()->setText(tmp);
+- }
+-}
+-
+-void MainWindow::bitsChanged(int b)
+-{
+- n.subnet_bits=b;
+- ipsc_network_init(&n);
+- QString tmp;
+- tmp.sprintf("%s/%d", denumberize(n.host_addr),ipsc_network_get_prefix_bits(&n));
+- networkAddress->lineEdit()->setText(tmp);
+- updateAll();
+-}
+-
+-void MainWindow::showPage(int t)
+-{
+- if ( t==CIDR_VIEW )
+- {
+- bitsLabel->setText("Supnet bits");
+- subnetBits->setMaxValue(31);
+- }
+- else
+- {
+- bitsLabel->setText("Subnet bits");
+- subnetBits->setMaxValue(n.subnet_bits_max);
+- }
+- pageView->raiseWidget(t);
+-
+-}
+-
+-
+-
+-void MainWindow::updateAll()
+-{
+- subnetBits->setMaxValue(n.subnet_bits_max);
+- for ( unsigned int i=0;i<T_LAST;i++ )
+- updatePage(i);
+-
+-}
+-
+-void MainWindow::updatePage(int t)
+-{
+- QString text;
+-
+- text.append("<qt bgcolor="+dColor+">");
+- text.append("<table border=0 width=210>");
+-
+- switch ( t )
+- {
+- case GENERAL_VIEW:
+- updateGPage(text);
+- break;
+- case SUBNETS_VIEW:
+- updateSPage(text);
+- break;
+- case HOST_VIEW:
+- updateHPage(text);
+- break;
+- case CIDR_VIEW:
+- updateCPage(text);
+- break;
+- }
+-
+- text.append("</table></html>");
+-
+- pages[t]->setText(text);
+-
+-}
+-
+-void MainWindow::updateGPage(QString &s)
+-{
+- s.append("<tr><td width=50%><font color="+fColor+">Subnet maximum</font></td><td width=50%><font color="+fColor+">Addresses/Subnet</font></td></tr>");
+- s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString::number(n.subnet_max)+
+- "</td><td bgcolor="+lColor+" width=50%>"+QString::number(n.host_max)+"</td></tr>");
+- s.append("<tr><td width=100% colspan=2><font color="+fColor+">Bitmap (network,subnet,host)</font></td></tr>");
+- s.append("<tr><td width=100% bgcolor="+lColor+" colspan=2>"+QString(n.bitmap)+"</td></tr>");
+- s.append("<tr><td width=50%><font color="+fColor+">Class Mask</font></td><td width=50%><font color="+fColor+">Hex Class Mask</font></td></tr>");
+- QString tmp;
+- int fmask=ipsc_network_get_full_mask(&n);
+- tmp.sprintf("%X",n.mask);
+- s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.mask))+
+- "</td><td bgcolor="+lColor+" width=50%>"+tmp+"</td></tr>");
+- s.append("<tr><td width=50%><font color="+fColor+">Full Subnet Mask</font></td><td width=50%><font color="+fColor+">Full Hex Subnet Mask</font></td></tr>");
+- tmp.sprintf("%X",fmask);
+- s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize(fmask))+
+- "</td><td bgcolor="+lColor+" width=50%>"+tmp+"</td></tr>");
+-}
+-
+-void MainWindow::updateSPage(QString &s)
+-{
+- s.append("<tr><th width=10%>Subnet</th><th width=90% >Address range</th></tr>");
+-
+- unsigned int subnet_addr = n.addr;
+- QString tmp;
+-
+- for ( unsigned int i = 0; i < n.subnet_max; i++ )
+- {
+- tmp.sprintf("%s - ",denumberize(subnet_addr));
+- tmp.append(denumberize((subnet_addr + n.host_max-1)));
+- if ( ipsc_host_is_on_subnet(subnet_addr,&n) )
+- {
+- tmp.append(" *");
+- }
+- s.append("<tr><td bgcolor="+lColor+" width=10%>"+ QString::number(i+1)+
+- "</td><td bgcolor="+lColor+" width=90%>"+tmp+"</td></tr>");
+- subnet_addr += n.host_max;
+- if ( i==256 )
+- {
+- s.append("<tr><td colspan=2 bgcolor="+lColor+" width=10%>"+ QString::number(n.subnet_max-i-1)+
+- " more subnets ...</td></tr>");
+- break;
+- }
+- }
+-}
+-
+-void MainWindow::updateHPage(QString &s)
+-{
+- unsigned int lbound = ipsc_network_get_host_subnet_first_host(&n);
+- unsigned int ubound = ipsc_network_get_host_subnet_last_host(&n);
+-
+- QString tmp;
+- tmp.sprintf("%X",n.host_addr);
+- s.append("<tr><td width=50%><font color="+fColor+">IP Address</font></td><td width=50%><font color="+fColor+">Hex IP Address</font></td></tr>");
+- s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.host_addr))+
+- "</td><td bgcolor="+lColor+" width=50%>"+tmp+"</td></tr>");
+- tmp.sprintf("%s - ",denumberize(lbound));
+- tmp.append(denumberize(ubound));
+- s.append("<tr><td width=100% colspan=2><font color="+fColor+">Host Allocation Range</font></td></tr>");
+- s.append("<tr><td width=100% bgcolor="+lColor+" colspan=2>"+tmp+"</td></tr>");
+- s.append("<tr><td width=50%><font color="+fColor+">Subnet Mask</font></td><td width=50%><font color="+fColor+">Subnet ID</font></td></tr>");
+- s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.subnet_mask))+
+- "</td><td bgcolor="+lColor+" width=50%>"+QString(denumberize( ipsc_network_get_subnet_id(&n)))+"</td></tr>");
+- s.append("<tr><td width=50%><font color="+fColor+">Network ID</font></td><td width=50%><font color="+fColor+">Host ID</font></td></tr>");
+- s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize( ipsc_network_get_network_id(&n)))+
+- "</td><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.host_id))+"</td></tr>");
+-}
+-
+-void MainWindow::updateCPage(QString &s)
+-{
+- QString tmp;
+-
+- tmp.sprintf("%s/%d", denumberize(n.addr),ipsc_network_get_prefix_bits(&n));
+-
+- s.append("<tr><td width=50%><font color="+fColor+">CIDR Notation</font></td><td width=50%><font color="+fColor+">Supernet Maximum</font></td></tr>");
+- s.append("<tr><td bgcolor="+lColor+" width=50%>"+tmp+
+- "</td><td bgcolor="+lColor+" width=50%>"+QString::number(ipsc_network_get_supernet_max(&n))+"</td></tr>");
+- tmp.sprintf("%s/%d", denumberize(n.addr), n.bits);
+- s.append("<tr><td width=50%><font color="+fColor+">Classful Network</font></td><td width=50%><font color="+fColor+">Cisco Wildcard</font></td></tr>");
+- s.append("<tr><td bgcolor="+lColor+" width=50%>"+tmp+
+- "</td><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.cisco_wildcard))+"</td></tr>");
+- tmp.sprintf("%s / ", denumberize(n.addr));
+- tmp.append(denumberize(ipsc_network_get_full_mask(&n)));
+- s.append("<tr><td width=100% colspan=2><font color="+fColor+">Route/Mask</font></td></tr>");
+- s.append("<tr><td width=100% bgcolor="+lColor+" colspan=2>"+tmp+"</td></tr>");
+- tmp.sprintf("%X / %X", n.addr,ipsc_network_get_full_mask(&n));
+- s.append("<tr><td width=100% colspan=2><font color="+fColor+">Hex Route/Mask</font></td></tr>");
+- s.append("<tr><td width=100% bgcolor="+lColor+" colspan=2>"+tmp+"</td></tr>");
+-
+-
+-}
+-
+-void MainWindow::saveVariables()
+-{
+- Config cfg("zIPSC");
+- cfg.setGroup("zIPSC");
+-
+- QStringList ls;
+-
+- for ( int i=0;i<networkAddress->count();i++ )
+- {
+- ls.append(networkAddress->text(i));
+- }
+- QString tmp;
+- tmp.sprintf("%s/%d", denumberize(n.host_addr),ipsc_network_get_prefix_bits(&n));
+- cfg.writeEntry("NetAddress",tmp);
+- cfg.writeEntry("SubnetBits",(int)n.subnet_bits);
+- cfg.writeEntry("HItems",ls,'|');
+-}
+-
+-void MainWindow::initVariables()
+-{
+- Config cfg("zIPSC");
+- cfg.setGroup("zIPSC");
+-
+- networkAddress->insertStringList ( cfg.readListEntry("HItems",'|'));
+- QString net=cfg.readEntry("NetAddress","127.0.0.1/8");
+- networkAddress->lineEdit()->setText(net);
+- ipsc_network_init_parse_text(&n,net.latin1());
+- n.subnet_bits=cfg.readNumEntry ("SubnetBits", 0 );
+- ipsc_network_init(&n);
+- subnetBits->setMaxValue(n.subnet_bits_max);
+- subnetBits->setValue(n.subnet_bits);
+- processType=false;
+- addressType->select((int)(tolower(n.nclass)-'a'));
+- processType=true;
+- updateAll();
+-}
+-
+-void MainWindow::saveFile()
+-{
+- QString tmp;
+- tmp.sprintf("%s/%d", denumberize(n.host_addr),ipsc_network_get_prefix_bits(&n));
+- tmp.replace(QRegExp("[./]"),"_");
+- tmp.append(".txt");
+- QString fileName=InputDialog::getText("zIPSC","Save as ...",tmp,this);
+- if ( fileName.isEmpty() )
+- return;
+- fileName=QDir::home().absFilePath(fileName);
+- FILE *f;
+-
+- if ( (f = fopen((const char *)fileName.latin1() , "a")) == NULL )
+- {
+- QMessageBox::warning (this,"zIPSC","Error creating "+ fileName +".",0);
+- return;
+- }
+- ipsc_network_fprint_general(&n, f);
+- ipsc_network_fprint_host(&n, f);
+- ipsc_network_fprint_cidr(&n, f);
+- fclose(f);
+-
+-}
+-
+-void MainWindow::copyText()
+-{
+- QTextBrowser *tb=(QTextBrowser*)pageView->visibleWidget();
+- if ( tb && tb->hasSelectedText() )
+- {
+- tb->copy();
+- }
+-}
+-
+-void MainWindow::displayAbout()
+-{
+-
+- AboutDialog::displayAbout(QPixmap(QPEApplication::qpeDir()+"pics/zipsc.png"),
+- "zIPSC","<qt><b><h2>zIPSC</h2></b></qt>",
+- "<qt><hr>IP subnet calculator<p>Ported to Qtopia by Walter Rawdanik (zaurus@warmi.net)
+- <p>Based on 'IPSC' (http://ipsc.sourceforge.net/software.html)<p>Licensed under GNU General Public License</qt>",
+- this);}
+-
+-
+-
++/**********************************************************************
++** Copyright (C) 2002 Walter Rawdanik. All rights reserved.
++**
++** This file is part of zipsc application for Qtopia Environment.
++**
++** Issues:
++** Due to incomplete design of QueryResult which returns pointer instead of object, it needs to be explicitly
++** deleted after each use. Extremely error-prone and basically pain-in the ass.
++** I am still no 100% sure I completely understand Qt layouts. It seems that QComboBox grows to the size of the
++** widest string in it which causes it to go beyond the edge of the screen on Qtopia small screen.
++** The only solution I could find was to call setMaximumSize() on each with some hard coded magic number that
++** looks about right - not a good solution.
++**
++**
++** This file may be distributed and/or modified under the terms of the
++** GPL license appearing in the file LICENSE included in the
++** packaging of this file.
++** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
++** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++**
++**********************************************************************/
++#include <qpe/qpeapplication.h>
++#include <qpe/config.h>
++#include <qpe/fileselector.h>
++#include "MainWindow.h"
++#include <stdlib.h>
++#include <stdio.h>
++#include <ctype.h>
++#include <qlayout.h>
++#include <qframe.h>
++#include <qlistbox.h>
++#include <qlabel.h>
++#include <qcombobox.h>
++#include <qwidgetstack.h>
++#include <qlineedit.h>
++#include <qpushbutton.h>
++#include <qstringlist.h>
++#include <qmessagebox.h>
++#include <qtabbar.h>
++#include <qtoolbutton.h>
++#include <qtextbrowser.h>
++#include <qspinbox.h>
++#include <qpe/menubutton.h>
++#include <qpe/qpetoolbar.h>
++#include "InputDialog.h"
++#include <qdir.h>
++#include <qfile.h>
++
++AboutDialog::AboutDialog(const QPixmap &icon,const QString &caption, const QString &t,const QString &l,QWidget *parent):QDialog(parent,0,true)
++{
++ setCaption(caption);
++
++ if ( parent )
++ {
++ setPalette(parent->palette());
++ }
++
++ setMinimumSize(220,160);
++ QGridLayout *gl= new QGridLayout(this,2,2,4,2);
++ gl->addRowSpacing ( 0,0);
++ pix=new QLabel(this);
++ pix->setPixmap(icon);
++ gl->addWidget(pix,0,0);
++ title=new QLabel(t,this);
++ gl->addWidget(title,0,1);
++ label=new QLabel(l,this);
++ gl->addMultiCellWidget(label,1,1,0,1);
++
++}
++
++void AboutDialog::displayAbout(const QPixmap &icon,const QString &caption,const QString &t, const QString &text, QWidget *parent)
++{
++ AboutDialog *dlg=new AboutDialog(icon,caption,t,text,parent);
++ dlg->exec();
++ delete dlg;
++}
++
++MainWindow::MainWindow( QWidget* parent, const char* name, WFlags f )
++: QMainWindow( parent, name, f )
++{
++ setCaption("zIPSC");
++
++ lColor="#f8f8f8";
++ dColor="#e8e8e8";
++ fColor="#848484";
++ memset(&n, 0, sizeof(n));
++ processType=true;
++
++ QBoxLayout *topLayout=new QVBoxLayout(this,1);
++
++
++ //QFrame *topFrame=new QFrame (this);
++ //topFrame->setMaximumWidth(240);
++
++ QGridLayout *gl= new QGridLayout(this,3,6,2,2);
++ gl->addColSpacing ( 1,4);
++
++ topLayout->addLayout(gl);
++ gl->setColStretch(0,0);
++ gl->setColStretch(2,10);
++
++ QLabel *lb=new QLabel("Address:",this);
++ gl->addWidget(lb,0,0);
++ networkAddress= new QComboBox(true,this);
++ gl->addMultiCellWidget(networkAddress,0,0,2,4);
++ go= new QPushButton("Go",this);
++ gl->addWidget(go,0,5);
++ lb=new QLabel("Type:",this);
++ gl->addWidget(lb,1,0);
++
++ addressType= new MenuButton ( this);
++ addressType->insertItem("Class A (1.x.x.x - 126.x.x.x)");
++ addressType->insertItem("Class B (128.x.x.x - 191.x.x.x)");
++ addressType->insertItem("Class C (192.x.x.x - 223.x.x.x)");
++ gl->addMultiCellWidget(addressType,1,1,2,5);
++
++ bitsLabel=new QLabel("Subnet bits:",this);
++ gl->addWidget(bitsLabel,2,0);
++ subnetBits= new QSpinBox(this);
++ gl->addWidget(subnetBits,2,2,AlignLeft);
++
++ saveB=new QToolButton(this);
++ saveB->setAutoRaise(false);
++ saveB->setPixmap(QPixmap(QPEApplication::qpeDir()+"pics/zipsc/filesave.png_"));
++ gl->addWidget(saveB,2,3);
++ copyB=new QToolButton(this);
++ copyB->setAutoRaise(false);
++ copyB->setPixmap(QPixmap(QPEApplication::qpeDir()+"pics/zipsc/editcopy.png_"));
++ gl->addWidget(copyB,2,4);
++ aboutB=new QToolButton(this);
++ aboutB->setAutoRaise(false);
++ aboutB->setPixmap(QPixmap(QPEApplication::qpeDir()+"pics/zipsc/about.png_"));
++ gl->addWidget(aboutB,2,5);
++
++ topLayout->addSpacing(4);
++
++ int i;
++
++ switcher= new QTabBar(this);
++ switcher->setShape(QTabBar::RoundedAbove);
++
++ const char *tLabels[]={"General","Subnets/Hosts","Host","CIDR"};
++
++ for ( i=0;i<T_LAST;i++ )
++ {
++ tabValues[i]=switcher->addTab(new QTab(tLabels[i]));
++ }
++ switcher->setCurrentTab(0);
++ topLayout->addWidget(switcher);
++
++
++
++ pageView=new QWidgetStack(this);
++ for ( i=0;i<T_LAST;i++ )
++ {
++ pages[i]=new QTextBrowser(pageView);
++ pages[i]->setHScrollBarMode(QScrollView::AlwaysOff);
++ pageView->addWidget(pages[i],i);
++ }
++
++ topLayout->addWidget(pageView,10);
++
++
++ initVariables();
++ showPage(GENERAL_VIEW);
++
++
++ connect(switcher,SIGNAL(selected(int)),SLOT(showPage(int)));
++ connect(networkAddress->lineEdit(),SIGNAL(returnPressed()),SLOT(goButtonClicked()));
++ connect(go,SIGNAL(clicked()),SLOT(goButtonClicked()));
++ connect(addressType,SIGNAL(selected (int)),SLOT(typeButtonPressed(int)));
++ connect(subnetBits,SIGNAL(valueChanged (int)),SLOT(bitsChanged(int)));
++ connect(saveB,SIGNAL(clicked()),SLOT(saveFile()));
++ connect(copyB,SIGNAL(clicked()),SLOT(copyText()));
++ connect(aboutB,SIGNAL(clicked()),SLOT(displayAbout()));
++
++
++}
++
++MainWindow::~MainWindow()
++{
++ saveVariables();
++}
++
++
++void MainWindow::goButtonClicked()
++{
++ QString searchTerm=networkAddress->currentText();
++
++ if ( searchTerm.isEmpty() )
++ return;
++
++ if ( ipsc_network_init_parse_text(&n, searchTerm) < 0 )
++ {
++ QMessageBox::warning (this,"zIPSC","Incorrect network address",0);
++ }
++
++ ipsc_network_init_parse_text(&n,searchTerm);
++ updateAll();
++
++ // implement history .... if selected text already exists, delete it from the list ... if there are more than 10 items delete last used
++ QListBox *lb=networkAddress->listBox();
++
++ for ( unsigned int i=0;i<lb->count();i++ )
++ {
++ if ( searchTerm.upper()==lb->text(i).upper() )
++ {
++ lb->removeItem(i);
++ break;
++ }
++ }
++ if ( networkAddress->count()>16 )
++ networkAddress->removeItem(networkAddress->count()-1);
++ networkAddress->insertItem(searchTerm,0);
++
++ processType=false;
++ subnetBits->setValue(n.subnet_bits);
++ addressType->select((int)(tolower(n.nclass)-'a'));
++ processType=true;
++
++}
++
++void MainWindow::typeButtonPressed(int i)
++{
++ if ( processType )
++ {
++ char cl='a'+(int)i;
++
++ ipsc_network_set_class_info(&n, cl, TRUE);
++ ipsc_network_init(&n);
++ updateAll();
++
++ QString tmp;
++ tmp.sprintf("%s/%d", denumberize(n.host_addr),ipsc_network_get_prefix_bits(&n));
++ networkAddress->lineEdit()->setText(tmp);
++ }
++}
++
++void MainWindow::bitsChanged(int b)
++{
++ n.subnet_bits=b;
++ ipsc_network_init(&n);
++ QString tmp;
++ tmp.sprintf("%s/%d", denumberize(n.host_addr),ipsc_network_get_prefix_bits(&n));
++ networkAddress->lineEdit()->setText(tmp);
++ updateAll();
++}
++
++void MainWindow::showPage(int t)
++{
++ if ( t==CIDR_VIEW )
++ {
++ bitsLabel->setText("Supnet bits");
++ subnetBits->setMaxValue(31);
++ }
++ else
++ {
++ bitsLabel->setText("Subnet bits");
++ subnetBits->setMaxValue(n.subnet_bits_max);
++ }
++ pageView->raiseWidget(t);
++
++}
++
++
++
++void MainWindow::updateAll()
++{
++ subnetBits->setMaxValue(n.subnet_bits_max);
++ for ( unsigned int i=0;i<T_LAST;i++ )
++ updatePage(i);
++
++}
++
++void MainWindow::updatePage(int t)
++{
++ QString text;
++
++ text.append("<qt bgcolor="+dColor+">");
++ text.append("<table border=0 width=210>");
++
++ switch ( t )
++ {
++ case GENERAL_VIEW:
++ updateGPage(text);
++ break;
++ case SUBNETS_VIEW:
++ updateSPage(text);
++ break;
++ case HOST_VIEW:
++ updateHPage(text);
++ break;
++ case CIDR_VIEW:
++ updateCPage(text);
++ break;
++ }
++
++ text.append("</table></html>");
++
++ pages[t]->setText(text);
++
++}
++
++void MainWindow::updateGPage(QString &s)
++{
++ s.append("<tr><td width=50%><font color="+fColor+">Subnet maximum</font></td><td width=50%><font color="+fColor+">Addresses/Subnet</font></td></tr>");
++ s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString::number(n.subnet_max)+
++ "</td><td bgcolor="+lColor+" width=50%>"+QString::number(n.host_max)+"</td></tr>");
++ s.append("<tr><td width=100% colspan=2><font color="+fColor+">Bitmap (network,subnet,host)</font></td></tr>");
++ s.append("<tr><td width=100% bgcolor="+lColor+" colspan=2>"+QString(n.bitmap)+"</td></tr>");
++ s.append("<tr><td width=50%><font color="+fColor+">Class Mask</font></td><td width=50%><font color="+fColor+">Hex Class Mask</font></td></tr>");
++ QString tmp;
++ int fmask=ipsc_network_get_full_mask(&n);
++ tmp.sprintf("%X",n.mask);
++ s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.mask))+
++ "</td><td bgcolor="+lColor+" width=50%>"+tmp+"</td></tr>");
++ s.append("<tr><td width=50%><font color="+fColor+">Full Subnet Mask</font></td><td width=50%><font color="+fColor+">Full Hex Subnet Mask</font></td></tr>");
++ tmp.sprintf("%X",fmask);
++ s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize(fmask))+
++ "</td><td bgcolor="+lColor+" width=50%>"+tmp+"</td></tr>");
++}
++
++void MainWindow::updateSPage(QString &s)
++{
++ s.append("<tr><th width=10%>Subnet</th><th width=90% >Address range</th></tr>");
++
++ unsigned int subnet_addr = n.addr;
++ QString tmp;
++
++ for ( unsigned int i = 0; i < n.subnet_max; i++ )
++ {
++ tmp.sprintf("%s - ",denumberize(subnet_addr));
++ tmp.append(denumberize((subnet_addr + n.host_max-1)));
++ if ( ipsc_host_is_on_subnet(subnet_addr,&n) )
++ {
++ tmp.append(" *");
++ }
++ s.append("<tr><td bgcolor="+lColor+" width=10%>"+ QString::number(i+1)+
++ "</td><td bgcolor="+lColor+" width=90%>"+tmp+"</td></tr>");
++ subnet_addr += n.host_max;
++ if ( i==256 )
++ {
++ s.append("<tr><td colspan=2 bgcolor="+lColor+" width=10%>"+ QString::number(n.subnet_max-i-1)+
++ " more subnets ...</td></tr>");
++ break;
++ }
++ }
++}
++
++void MainWindow::updateHPage(QString &s)
++{
++ unsigned int lbound = ipsc_network_get_host_subnet_first_host(&n);
++ unsigned int ubound = ipsc_network_get_host_subnet_last_host(&n);
++
++ QString tmp;
++ tmp.sprintf("%X",n.host_addr);
++ s.append("<tr><td width=50%><font color="+fColor+">IP Address</font></td><td width=50%><font color="+fColor+">Hex IP Address</font></td></tr>");
++ s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.host_addr))+
++ "</td><td bgcolor="+lColor+" width=50%>"+tmp+"</td></tr>");
++ tmp.sprintf("%s - ",denumberize(lbound));
++ tmp.append(denumberize(ubound));
++ s.append("<tr><td width=100% colspan=2><font color="+fColor+">Host Allocation Range</font></td></tr>");
++ s.append("<tr><td width=100% bgcolor="+lColor+" colspan=2>"+tmp+"</td></tr>");
++ s.append("<tr><td width=50%><font color="+fColor+">Subnet Mask</font></td><td width=50%><font color="+fColor+">Subnet ID</font></td></tr>");
++ s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.subnet_mask))+
++ "</td><td bgcolor="+lColor+" width=50%>"+QString(denumberize( ipsc_network_get_subnet_id(&n)))+"</td></tr>");
++ s.append("<tr><td width=50%><font color="+fColor+">Network ID</font></td><td width=50%><font color="+fColor+">Host ID</font></td></tr>");
++ s.append("<tr><td bgcolor="+lColor+" width=50%>"+QString(denumberize( ipsc_network_get_network_id(&n)))+
++ "</td><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.host_id))+"</td></tr>");
++}
++
++void MainWindow::updateCPage(QString &s)
++{
++ QString tmp;
++
++ tmp.sprintf("%s/%d", denumberize(n.addr),ipsc_network_get_prefix_bits(&n));
++
++ s.append("<tr><td width=50%><font color="+fColor+">CIDR Notation</font></td><td width=50%><font color="+fColor+">Supernet Maximum</font></td></tr>");
++ s.append("<tr><td bgcolor="+lColor+" width=50%>"+tmp+
++ "</td><td bgcolor="+lColor+" width=50%>"+QString::number(ipsc_network_get_supernet_max(&n))+"</td></tr>");
++ tmp.sprintf("%s/%d", denumberize(n.addr), n.bits);
++ s.append("<tr><td width=50%><font color="+fColor+">Classful Network</font></td><td width=50%><font color="+fColor+">Cisco Wildcard</font></td></tr>");
++ s.append("<tr><td bgcolor="+lColor+" width=50%>"+tmp+
++ "</td><td bgcolor="+lColor+" width=50%>"+QString(denumberize(n.cisco_wildcard))+"</td></tr>");
++ tmp.sprintf("%s / ", denumberize(n.addr));
++ tmp.append(denumberize(ipsc_network_get_full_mask(&n)));
++ s.append("<tr><td width=100% colspan=2><font color="+fColor+">Route/Mask</font></td></tr>");
++ s.append("<tr><td width=100% bgcolor="+lColor+" colspan=2>"+tmp+"</td></tr>");
++ tmp.sprintf("%X / %X", n.addr,ipsc_network_get_full_mask(&n));
++ s.append("<tr><td width=100% colspan=2><font color="+fColor+">Hex Route/Mask</font></td></tr>");
++ s.append("<tr><td width=100% bgcolor="+lColor+" colspan=2>"+tmp+"</td></tr>");
++
++
++}
++
++void MainWindow::saveVariables()
++{
++ Config cfg("zIPSC");
++ cfg.setGroup("zIPSC");
++
++ QStringList ls;
++
++ for ( int i=0;i<networkAddress->count();i++ )
++ {
++ ls.append(networkAddress->text(i));
++ }
++ QString tmp;
++ tmp.sprintf("%s/%d", denumberize(n.host_addr),ipsc_network_get_prefix_bits(&n));
++ cfg.writeEntry("NetAddress",tmp);
++ cfg.writeEntry("SubnetBits",(int)n.subnet_bits);
++ cfg.writeEntry("HItems",ls,'|');
++}
++
++void MainWindow::initVariables()
++{
++ Config cfg("zIPSC");
++ cfg.setGroup("zIPSC");
++
++ networkAddress->insertStringList ( cfg.readListEntry("HItems",'|'));
++ QString net=cfg.readEntry("NetAddress","127.0.0.1/8");
++ networkAddress->lineEdit()->setText(net);
++ ipsc_network_init_parse_text(&n,net.latin1());
++ n.subnet_bits=cfg.readNumEntry ("SubnetBits", 0 );
++ ipsc_network_init(&n);
++ subnetBits->setMaxValue(n.subnet_bits_max);
++ subnetBits->setValue(n.subnet_bits);
++ processType=false;
++ addressType->select((int)(tolower(n.nclass)-'a'));
++ processType=true;
++ updateAll();
++}
++
++void MainWindow::saveFile()
++{
++ QString tmp;
++ tmp.sprintf("%s/%d", denumberize(n.host_addr),ipsc_network_get_prefix_bits(&n));
++ tmp.replace(QRegExp("[./]"),"_");
++ tmp.append(".txt");
++ QString fileName=InputDialog::getText("zIPSC","Save as ...",tmp,this);
++ if ( fileName.isEmpty() )
++ return;
++ fileName=QDir::home().absFilePath(fileName);
++ FILE *f;
++
++ if ( (f = fopen((const char *)fileName.latin1() , "a")) == NULL )
++ {
++ QMessageBox::warning (this,"zIPSC","Error creating "+ fileName +".",0);
++ return;
++ }
++ ipsc_network_fprint_general(&n, f);
++ ipsc_network_fprint_host(&n, f);
++ ipsc_network_fprint_cidr(&n, f);
++ fclose(f);
++
++}
++
++void MainWindow::copyText()
++{
++ QTextBrowser *tb=(QTextBrowser*)pageView->visibleWidget();
++ if ( tb && tb->hasSelectedText() )
++ {
++ tb->copy();
++ }
++}
++
++void MainWindow::displayAbout()
++{
++
++ AboutDialog::displayAbout(QPixmap(QPEApplication::qpeDir()+"pics/zipsc.png"),
++ "zIPSC","<qt><b><h2>zIPSC</h2></b></qt>",
++ "<qt><hr>IP subnet calculator<p>Ported to Qtopia by Walter Rawdanik (zaurus@warmi.net) "
++ "<p>Based on 'IPSC' (http://ipsc.sourceforge.net/software.html)<p>Licensed under GNU General Public License</qt>",
++ this);
++}
++
++
++