Commit 40ab728a authored by nobody's avatar nobody

This commit was manufactured by cvs2svn to create tag

'KDE_3_2_3_RELEASE'.

svn path=/tags/KDE_3_2_3_RELEASE/kdeedu/kstars/; revision=316997
parents f452c338 a3091a3c
bin_PROGRAMS = kstars
kstars_SOURCES = kspluto.cpp addcatdialog.cpp addlinkdialog.cpp astrocalc.cpp colorscheme.cpp detaildialog.cpp dmsbox.cpp dms.cpp altvstime.cpp filesource.cpp finddialog.cpp focusdialog.cpp geolocation.cpp imageviewer.cpp indidevice.cpp indidriver.cpp indimenu.cpp infobox.cpp infoboxes.cpp jmoontool.cpp jupitermoons.cpp ksasteroid.cpp kscomet.cpp ksfilereader.cpp ksmoon.cpp ksnumbers.cpp ksplanetbase.cpp ksplanet.cpp kspopupmenu.cpp kssun.cpp kstarsactions.cpp kstars.cpp kstarsdata.cpp kstarsdcop.cpp kstarsinit.cpp kstarsoptions.cpp kstars_options_handling.cpp kstarsplotwidget.cpp kstarssplash.cpp ksutils.cpp lcgenerator.cpp locationdialog.cpp magnitudespinbox.cpp main.cpp mapcanvas.cpp modcalcapcoord.cpp modcalcazel.cpp modcalcdaylength.cpp modcalcgalcoord.cpp modcalcgeodcoord.cpp modcalcjd.cpp modcalcprec.cpp modcalcsidtime.cpp objectnamelist.cpp planetcatalog.cpp planetviewer.cpp scriptbuilder.cpp scriptfunction.cpp simclock.cpp skymap.cpp skymapdraw.cpp skymapevents.cpp skyobject.cpp skyobjectname.cpp skypoint.cpp stardatasink.cpp starobject.cpp starpixmap.cpp telescopewizardprocess.cpp timebox.cpp timedialog.cpp timespinbox.cpp timestepbox.cpp timeunitbox.cpp timezonerule.cpp toggleaction.cpp viewopsdialog.cpp wutdialog.cpp argchangeviewoption.ui arglooktoward.ui argsetaltaz.ui argsetgeolocation.ui argsetlocaltime.ui argsetradec.ui argsettrack.ui argtimescale.ui argwaitforkey.ui argwaitfor.ui argzoom.ui devmanager.ui focusdialogdlg.ui indiconf.ui indihostconf.ui modcalcapcoorddlg.ui modcalcazeldlg.ui modcalcdaylengthdlg.ui modcalcgalcoorddlg.ui modcalcgeoddlg.ui modcalcjddlg.ui modcalcprecdlg.ui modcalcsidtimedlg.ui opsadvanced.ui opscatalog.ui opscolors.ui opsguides.ui opssolarsystem.ui optionstreeview.ui scriptbuilderui.ui scriptnamedialog.ui telescopewizard.ui kstarsinterface.skel simclockinterface.skel deepskyobject.cpp wutdialogui.ui fovdialog.cpp fovdialogui.ui newfovui.ui fov.cpp altvstimeui.ui
kstars_SOURCES = kspluto.cpp addcatdialog.cpp addlinkdialog.cpp astrocalc.cpp colorscheme.cpp detaildialog.cpp dmsbox.cpp dms.cpp altvstime.cpp filesource.cpp finddialog.cpp focusdialog.cpp geolocation.cpp imageviewer.cpp indidevice.cpp indidriver.cpp indimenu.cpp infobox.cpp infoboxes.cpp jmoontool.cpp jupitermoons.cpp ksasteroid.cpp kscomet.cpp ksfilereader.cpp ksmoon.cpp ksnumbers.cpp ksplanetbase.cpp ksplanet.cpp kspopupmenu.cpp kssun.cpp kstarsactions.cpp kstars.cpp kstarsdata.cpp kstarsdcop.cpp kstarsinit.cpp kstarsoptions.cpp kstars_options_handling.cpp kstarsplotwidget.cpp kstarssplash.cpp ksutils.cpp lcgenerator.cpp locationdialog.cpp magnitudespinbox.cpp main.cpp mapcanvas.cpp modcalcapcoord.cpp modcalcazel.cpp modcalcdaylength.cpp modcalcgalcoord.cpp modcalcgeodcoord.cpp modcalcjd.cpp modcalcprec.cpp modcalcsidtime.cpp objectnamelist.cpp planetcatalog.cpp planetviewer.cpp scriptbuilder.cpp scriptfunction.cpp simclock.cpp skymap.cpp skymapdraw.cpp skymapevents.cpp skyobject.cpp skyobjectname.cpp skypoint.cpp stardatasink.cpp starobject.cpp starpixmap.cpp telescopewizardprocess.cpp timebox.cpp timedialog.cpp timespinbox.cpp timestepbox.cpp timeunitbox.cpp timezonerule.cpp toggleaction.cpp viewopsdialog.cpp wutdialog.cpp argchangeviewoption.ui arglooktoward.ui argsetaltaz.ui argsetgeolocation.ui argsetlocaltime.ui argsetradec.ui argsettrack.ui argtimescale.ui argwaitforkey.ui argwaitfor.ui argzoom.ui devmanager.ui focusdialogdlg.ui indiconf.ui indihostconf.ui modcalcapcoorddlg.ui modcalcazeldlg.ui modcalcdaylengthdlg.ui modcalcgalcoorddlg.ui modcalcgeoddlg.ui modcalcjddlg.ui modcalcprecdlg.ui modcalcsidtimedlg.ui opsadvanced.ui opscatalog.ui opscolors.ui opsguides.ui opssolarsystem.ui optionstreeview.ui scriptbuilderui.ui scriptnamedialog.ui telescopewizard.ui kstarsinterface.skel simclockinterface.skel deepskyobject.cpp wutdialogui.ui fovdialog.cpp fovdialogui.ui newfovui.ui fov.cpp altvstimeui.ui devicemanager.cpp indielement.cpp indigroup.cpp indiproperty.cpp indistd.cpp
kstars_LDADD = indi/liblilxml.a indi/libindicom.a $(top_builddir)/libkdeedu/kdeeduplot/libkdeeduplot.la -lkdeprint -lm
SUBDIRS = data indi
SUBDIRS = data indi icons
EXTRA_DIST = kstars.desktop kstarsui.rc
# needed for sincos() GNU extension to math.h
KDE_CXXFLAGS = -D_GNU_SOURCE
xdg_apps_DATA = kstars.desktop
......
......@@ -2159,7 +2159,7 @@ Smyrna : Delaware : USA
Soda Springs : Idaho : USA : 42 : 38 : 59 : N : 111 : 37 : 1 : W : -7.0 : US
Soeborg : : Denmark : 55 : 25 : 12 : N : 12 : 20 : 59 : E : 1.0 : EU
Soenderborg : Jylland : Denmark : 54 : 55 : 1 : N : 9 : 46 : 1 : E : 1.0 : EU
Sofia : : Bulgary : 42 : 43 : 0 : N : 23 : 19 : 59 : E : 2.0 : EU
Sofia : : Bulgaria : 42 : 43 : 0 : N : 23 : 19 : 59 : E : 2.0 : EU
Sokcho : Gangwon : Korea : 38 : 15 : 0 : N : 128 : 34 : 0 : E : 9.0 : SK
Solingen : : Germany : 51 : 11 : 00 : N : 7 : 05 : 00 : E : 1.0 : EU
Somerset : Kentucky : USA : 37 : 2 : 23 : N : 84 : 21 : 35 : W : -5.0 : US
......
KDE_ICON = kstars
appdatadir = $(kde_datadir)/kstars
appdata_DATA = kstars.png geomap.png show_clines.png show_cnames.png show_deepsky.png \
show_grid.png show_horiz.png show_mw.png show_planets.png show_stars.png \
......
This diff is collapsed.
# File: info_url.dat
# version 1.0; last update: 09 March 2004
# by Jason Harris
# No copyright claimed, this is merely a list of "facts"
#
#Data file for KStars, specifying object-specific Web Page URLs.
#For Image URLs, see image_url.dat.
#
#Line format is: Object_Name:Label_String:URL
#The Object_Name needs to match an object's *primary* name!
#
#You should not need to modify this file;
#you can manage these links from within KStars.
#Please report broken links to kstars@30doradus.org !
#
# Messier Objects:
M 1:Wikipedia Page:http://en.wikipedia.org/wiki/Crab_Nebula
M 4:Wikipedia Page:http://en.wikipedia.org/wiki/Messier_4
M 13:Wikipedia Page:http://en.wikipedia.org/wiki/Hercules_Globular_Cluster
M 14:Wikipedia Page:http://en.wikipedia.org/wiki/Messier_14
M 16:Wikipedia Page:http://en.wikipedia.org/wiki/Eagle_Nebula
M 20:Wikipedia Page:http://en.wikipedia.org/wiki/Trifid_nebula
M 27:Wikipedia Page:http://en.wikipedia.org/wiki/Dumbbell_Nebula
M 31:Wikipedia Page:http://en.wikipedia.org/wiki/Andromeda_Galaxy
M 33:Wikipedia Page:http://en.wikipedia.org/wiki/Triangulum_Galaxy
M 42:Wikipedia Page:http://en.wikipedia.org/wiki/Orion_Nebula
M 45:Wikipedia Page:http://en.wikipedia.org/wiki/Pleiades
M 57:Wikipedia Page:http://en.wikipedia.org/wiki/Ring_Nebula
M 64:Wikipedia Page:http://en.wikipedia.org/wiki/Black_Eye_Galaxy
M 82:Wikipedia Page:http://en.wikipedia.org/wiki/M82
M 83:Wikipedia Page:http://en.wikipedia.org/wiki/Southern_Pinwheel_Galaxy
M 87:Wikipedia Page:http://en.wikipedia.org/wiki/Virgo_A_Galaxy
M 100:Wikipedia Page:http://en.wikipedia.org/wiki/M100
M 101:Wikipedia Page:http://en.wikipedia.org/wiki/Pinwheel_Galaxy
M 107:Wikipedia Page:http://en.wikipedia.org/wiki/Messier_107
M 1:SEDS Information Page:http://www.seds.org/messier/m/m001.html
M 2:SEDS Information Page:http://www.seds.org/messier/m/m002.html
M 3:SEDS Information Page:http://www.seds.org/messier/m/m003.html
......@@ -109,19 +144,41 @@ M 108:SEDS Information Page:http://www.seds.org/messier/m/m108.html
M 109:SEDS Information Page:http://www.seds.org/messier/m/m109.html
M 110:SEDS Information Page:http://www.seds.org/messier/m/m110.html
M 1:HST Press Release (2002):http://oposite.stsci.edu/pubinfo/PR/2002/24/pr.html
#
# NGC Objects
NGC 2070:Wikipedia Page:http://en.wikipedia.org/wiki/NGC_2070
NGC 2264:Wikipedia Page:http://en.wikipedia.org/wiki/NGC_2264
NGC 2346:Wikipedia Page:http://en.wikipedia.org/wiki/NGC_2346
NGC 2392:Wikipedia Page:http://en.wikipedia.org/wiki/Eskimo_Nebula
NGC 5866:Wikipedia Page:http://en.wikipedia.org/wiki/NGC_5866
NGC 6240:Wikipedia Page:http://en.wikipedia.org/wiki/Starfish_Galaxy
NGC 6537:Wikipedia Page:http://en.wikipedia.org/wiki/Red_Spider_Nebula
NGC 6543:Wikipedia Page:http://en.wikipedia.org/wiki/Cat's_Eye_Nebula
NGC 7000:Wikipedia Page:http://en.wikipedia.org/wiki/North_American_Nebula
NGC_7742:Wikipedia Page:http://en.wikipedia.org/wiki/NGC_7742
#
# IC Objects
IC 10:Wikipedia Page:http://en.wikipedia.org/wiki/IC_10
#
# Major Planets, Sun and Moon:
Sun:Wikipedia Page:http://en.wikipedia.org/wiki/Sun
Sun:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/sol.html
Sun:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/sun/sun_index.html
Sun:Daily Solar Images:http://umbra.nascom.nasa.gov/images/latest.html
Sun:Fred Espanek's Eclipse page:http://sunearth.gsfc.nasa.gov/eclipse/eclipse.html
Moon:Wikipedia Page:http://en.wikipedia.org/wiki/Moon
Moon:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/luna.html
Moon:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/moon_index.html
Moon:The Apollo Program:http://www.nasm.edu/apollo/
Moon:The Apollo Program:http://www.nasm.si.edu/collections/imagery/apollo/apollo.htm
Mercury:Wikipedia Page:http://en.wikipedia.org/wiki/Mercury_(planet)
Mercury:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/mercury.html
Mercury:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/planets_index.html
Mercury:The Mariner 10 Mission:http://nssdc.gsfc.nasa.gov/nmc/tmp/1973-085A.html
Venus:Wikipedia Page:http://en.wikipedia.org/wiki/Venus_(planet)
Venus:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/venus.html
Venus:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/venus_index.html
Venus:The Magellan Mission:http://www.jpl.nasa.gov/magellan/
Mars:Wikipedia Page:http://en.wikipedia.org/wiki/Mars_(planet)
Mars:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/mars.html
Mars:NASA Mars Missions:http://mars.jpl.nasa.gov/index.html
Mars:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/mars_index.html
......@@ -129,21 +186,57 @@ Mars:Welcome to Mars!:http://www.amnh.org/rose/mars/index.html
Mars:The Whole Mars Catalog:http://www.spaceref.com/mars/
Mars:The Mars Society:http://www.marssociety.org/
Mars:The "face" on Mars:http://mars.jpl.nasa.gov/mgs/msss/camera/images/moc_5_24_01/face/index.html
Jupiter:Wikipedia Page:http://en.wikipedia.org/wiki/Jupiter_(planet)
Jupiter:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/jupiter.html
Jupiter:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/jupiter_index.html
Jupiter:The Galileo Mission:http://www.jpl.nasa.gov/galileo/
Jupiter:The Voyager Missions:http://voyager.jpl.nasa.gov/
Jupiter:Comet Shoemaker-Levy 9:http://www.seds.org/nineplanets/nineplanets/sl9.html
Saturn:Wikipedia Page:http://en.wikipedia.org/wiki/Saturn_(planet)
Saturn:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/saturn.html
Saturn:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/saturn_index.html
Saturn:The Cassini Mission:http://saturn.jpl.nasa.gov/index.cfm
Saturn:The Voyager Missions:http://voyager.jpl.nasa.gov/
Uranus:Wikipedia Page:http://en.wikipedia.org/wiki/Uranus_(planet)
Uranus:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/uranus.html
Uranus:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/uranus_index.html
Uranus:The Voyager Missions:http://voyager.jpl.nasa.gov/
Neptune:Wikipedia Page:http://en.wikipedia.org/wiki/Neptune_(planet)
Neptune:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/neptune.html
Neptune:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/neptune_index.html
Neptune:The Voyager Missions:http://voyager.jpl.nasa.gov/
Pluto:Wikipedia Page:http://en.wikipedia.org/wiki/Pluto_(planet)
Pluto:SEDS Information Page:http://www.seds.org/nineplanets/nineplanets/pluto.html
Pluto:NASA JPL Page:http://www.jpl.nasa.gov/solar_system/planets/pluto_index.html
Quaoar:Wikipedia Page:http://en.wikipedia.org/wiki/Quaoar
#
# Asteroids:
Ceres:Wikipedia Page:http://en.wikipedia.org/wiki/1_Ceres
Pallas:Wikipedia Page:http://en.wikipedia.org/wiki/2_Pallas
Vesta:Wikipedia Page:http://en.wikipedia.org/wiki/4_Vesta
Cybele:Wikipedia Page:http://en.wikipedia.org/wiki/65_Cybele
## --==>> There are 2 bodies named "Europa"...asteroid and Jovian moon
Europa:Wikipedia Page:http://en.wikipedia.org/wiki/52_Europa
Psyche:Wikipedia Page:http://en.wikipedia.org/wiki/16_Psyche
Juno:Wikipedia Page:http://en.wikipedia.org/wiki/3_Juno
Themis:Wikipedia Page:http://en.wikipedia.org/wiki/24_Themis
Astraea:Wikipedia Page:http://en.wikipedia.org/wiki/5_Astraea
Lumen:Wikipedia Page:http://en.wikipedia.org/wiki/141_Lumen
Ida:Wikipedia Page:http://en.wikipedia.org/wiki/243_Ida
Mathilde:Wikipedia Page:http://en.wikipedia.org/wiki/253_Mathilde
Eros:Wikipedia Page:http://en.wikipedia.org/wiki/433_Eros
Hektor:Wikipedia Page:http://en.wikipedia.org/wiki/624_Hektor
Gaspra:Wikipedia Page:http://en.wikipedia.org/wiki/951_Gaspra
## --==>> There are two objects named "Chiron"...asteroid and comet
Chiron:Wikipedia Page:http://en.wikipedia.org/wiki/2060_Chiron
#
# Comets:
Encke:Wikipedia Page:http://en.wikipedia.org/wiki/Comet_Encke
Hale-Bopp (1995 O1):Wikipedia Page:http://en.wikipedia.org/wiki/Comet_Hale-Bopp
Halley:Wikipedia Page:http://en.wikipedia.org/wiki/Comet_Halley
Hyakutake (1996 B2):Wikipedia Page:http://en.wikipedia.org/wiki/Comet_Hyakutake
Kohoutek:Wikipedia Page:http://en.wikipedia.org/wiki/Comet_Kohoutek
Wild 2:Wikipedia Page:http://en.wikipedia.org/wiki/Comet_Wild_2
#
#"XXX" entries will be removed from local copies when encountered in the global file.
XXX:Moon:About the Moon Images:http://www.astrosurf.com/cidadao/
/* Device Manager
Copyright (C) 2003 Jasem Mutlaq (mutlaqja@ikarustech.com)
This application 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 of the License, or (at your option) any later version.
JM Changelog
2004-16-1: Start
*/
#include "devicemanager.h"
#include "indimenu.h"
#include "indiproperty.h"
#include "indigroup.h"
#include "indidevice.h"
#include "kstars.h"
#include <qsocketnotifier.h>
#include <qtextedit.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <kstatusbar.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
/*******************************************************************
** The device manager contain devices running from one indiserver
** This allow KStars to control multiple devices distributed acorss
** multiple servers seemingly in a way that is completely transparent
** to devices and drivers alike.
** The device Manager can be thought of as the 'networking' parent
** of devices, while indimenu is 'GUI' parent of devices
*******************************************************************/
DeviceManager::DeviceManager(INDIMenu *INDIparent, int inID)
{
parent = INDIparent;
mgrID = inID;
indi_dev.setAutoDelete(true);
serverFD = -1;
serverFP = NULL;
XMLParser = NULL;
sNotifier = NULL;
}
DeviceManager::~DeviceManager()
{
if (serverFP)
fclose(serverFP);
if (serverFD >= 0)
close(serverFD);
if (XMLParser)
{
delLilXML(XMLParser);
XMLParser = NULL;
}
indi_dev.clear();
}
bool DeviceManager::indiConnect(QString host, QString port)
{
struct sockaddr_in pin;
struct hostent *serverHostName = gethostbyname(host.ascii());
QString errMsg;
errMsg = QString("Connection to INDI host at %1 on port %2 failed.").arg(host).arg(port);
memset(&pin, 0, sizeof(pin));
pin.sin_family = AF_INET;
pin.sin_addr.s_addr = ((struct in_addr *) (serverHostName->h_addr))->s_addr;
pin.sin_port = htons(port.toInt());
if ( (serverFD = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
KMessageBox::error(0, i18n("Can not create socket"));
return false;
}
if ( ::connect(serverFD, (struct sockaddr*) &pin, sizeof(pin)) == -1)
{
KMessageBox::error(0, errMsg);
serverFD = -1;
return false;
}
// callback notified
sNotifier = new QSocketNotifier( serverFD, QSocketNotifier::Read, this);
QObject::connect( sNotifier, SIGNAL(activated(int)), this, SLOT(dataReceived()));
if (XMLParser)
delLilXML(XMLParser);
XMLParser = newLilXML();
// ready for fprintf
serverFP = fdopen(serverFD, "w");
if (serverFP == NULL)
{
KMessageBox::error(0, i18n("Can't read server file descriptor"));
serverFD = -1;
return false;
}
setbuf (serverFP, NULL);
fprintf(serverFP, "<getProperties version='0.1'/>\n");
// We made it!
return true;
}
void DeviceManager::dataReceived()
{
char ibuf[32]; /* not so much user input lags */
char msg[1024];
int i, nr;
/* read INDI command */
nr = read (serverFD, ibuf, sizeof(ibuf));
if (nr <= 0)
{
if (nr < 0)
sprintf (msg, "INDI: input error.");
else
sprintf (msg, "INDI: agent closed connection.");
tcflush(serverFD, TCIFLUSH);
sNotifier->disconnect();
close(serverFD);
parent->removeDeviceMgr(mgrID);
KMessageBox::error(0, QString(msg));
return;
}
/* process each char */
for (i = 0; i < nr; i++)
{
if (!XMLParser)
return;
XMLEle *root = readXMLEle (XMLParser, (int)ibuf[i], msg);
if (root)
{
//prXMLEle (stdout, root, 0);
if (dispatchCommand(root, msg) < 0)
{
//kdDebug() << msg << endl;
fprintf(stderr, msg);
prXMLEle (stdout, root, 0);
}
delXMLEle (root);
}
else if (msg[0])
{
kdDebug() << msg << endl;
}
}
}
int DeviceManager::dispatchCommand(XMLEle *root, char errmsg[])
{
if (!strcmp (tagXMLEle(root), "message"))
return messageCmd(root, errmsg);
else if (!strcmp (tagXMLEle(root), "delProperty"))
return delPropertyCmd(root, errmsg);
/* Get the device, if not available, create it */
INDI_D *dp = findDev (root, 1, errmsg);
if (dp == NULL)
return -1;
if (!strcmp (tagXMLEle(root), "defTextVector"))
return dp->buildTextGUI(root, errmsg);
else if (!strcmp (tagXMLEle(root), "defNumberVector"))
return dp->buildNumberGUI(root, errmsg);
else if (!strcmp (tagXMLEle(root), "defSwitchVector"))
return dp->buildSwitchesGUI(root, errmsg);
else if (!strcmp (tagXMLEle(root), "defLightVector"))
return dp->buildLightsGUI(root, errmsg);
else if (!strcmp (tagXMLEle(root), "setTextVector") ||
!strcmp (tagXMLEle(root), "setNumberVector") ||
!strcmp (tagXMLEle(root), "setSwitchVector") ||
!strcmp (tagXMLEle(root), "setLightVector"))
return dp->setAnyCmd(root, errmsg);
return (-1);
}
/* delete the property in the given device, including widgets and data structs.
* when last property is deleted, delete the device too.
* if no property name attribute at all, delete the whole device regardless.
* return 0 if ok, else -1 with reason in errmsg[].
*/
int DeviceManager::delPropertyCmd (XMLEle *root, char errmsg[])
{
XMLAtt *ap;
INDI_D *dp;
INDI_P *pp;
/* dig out device and optional property name */
dp = findDev (root, 0, errmsg);
if (!dp)
return (-1);
checkMsg(root, dp);
ap = findXMLAtt (root, "name");
/* Delete property if it exists, otherwise, delete the whole device */
if (ap)
{
pp = dp->findProp(QString(valuXMLAtt(ap)));
if(pp)
return dp->removeProperty(pp);
else
return (-1);
}
// delete the whole device
else
return removeDevice(dp->name, errmsg);
}
int DeviceManager::removeDevice(QString devName, char errmsg[])
{
// remove all devices if devName == NULL
if (devName == NULL)
{
indi_dev.clear();
return (0);
}
for (unsigned int i=0; i < indi_dev.count(); i++)
{
if (indi_dev.at(i)->name == devName)
{
kdDebug() << "Device Manager: Device found, deleting " << devName << endl;
indi_dev.remove(i);
return (0);
}
}
sprintf(errmsg, "Device %s not found" , devName.ascii());
return -1;
}
INDI_D * DeviceManager::findDev (QString devName, char errmsg[])
{
/* search for existing */
for (unsigned int i = 0; i < indi_dev.count(); i++)
{
if (indi_dev.at(i)->name == devName)
return (indi_dev.at(i));
}
sprintf (errmsg, "INDI: no such device %s", devName.ascii());
kdDebug() << errmsg;
return NULL;
}
/* add new device to mainrc_w using info in dep.
- * if trouble return NULL with reason in errmsg[]
- */
INDI_D * DeviceManager::addDevice (XMLEle *dep, char errmsg[])
{
INDI_D *dp;
XMLAtt *ap;
/* allocate new INDI_D on indi_dev */
ap = findAtt (dep, "device", errmsg);
if (!ap)
return NULL;
if (parent->currentLabel.isEmpty())
parent->setCustomLabel(valuXMLAtt(ap));
dp = new INDI_D(parent, this, QString(valuXMLAtt(ap)), parent->currentLabel);
indi_dev.append(dp);
// Reset label
parent->currentLabel = "";
/* ok */
return dp;
}
INDI_D * DeviceManager::findDev (XMLEle *root, int create, char errmsg[])
{
XMLAtt *ap;
char *dn;
/* get device name */
ap = findAtt (root, "device", errmsg);
if (!ap)
return (NULL);
dn = valuXMLAtt(ap);
/* search for existing */
for (uint i = 0; i < indi_dev.count(); i++)
{
if (indi_dev.at(i)->name == QString(dn))
return (indi_dev.at(i));
}
/* not found, create if ok */
if (create)
return (addDevice (root, errmsg));
sprintf (errmsg, "INDI: <%s> no such device %s", tagXMLEle(root), dn);
return NULL;
}
/* a general message command received from the device.
* return 0 if ok, else -1 with reason in errmsg[].
*/
int DeviceManager::messageCmd (XMLEle *root, char errmsg[])
{
checkMsg (root, findDev (root, 0, errmsg));
return (0);
}
/* display message attribute.
* N.B. don't put carriage control in msg, we take care of that.
*/
void DeviceManager::checkMsg (XMLEle *root, INDI_D *dp)
{
XMLAtt *ap;
ap = findXMLAtt(root, "message");
if (ap)
doMsg(root, dp);
}
/* display valu of message and timestamp in dp's scrolled area, if any, else general.
* prefix our time stamp if not included.
* N.B. don't put carriage control in msg, we take care of that.
*/
void DeviceManager::doMsg (XMLEle *msg, INDI_D *dp)
{
QTextEdit *txt_w;
XMLAtt *message;
XMLAtt *timestamp;
/* determine whether device or generic message
FIXME: The policy now is that generic messages get posted in all windows but with
different color and/or font as to get attention. Make this configurable. Also make it
configurable to automatically save all INDI logs.
*/
/*if (dp)*/
txt_w = dp->msgST_w;
/*else
txt_w = parent->msgST_w;*/
/* prefix our timestamp if not with msg */
timestamp = findXMLAtt (msg, "timestamp");
if (timestamp)
txt_w->insert(QString(valuXMLAtt(timestamp)) + QString(" "));
else
txt_w->insert( (QDateTime().currentDateTime()).toString("yyyy/mm/dd - h:m:s ap "));
/* finally! the msg */
message = findXMLAtt(msg, "message");
txt_w->insert( QString(valuXMLAtt(message)) + QString("\n"));
if (parent->ksw->options()->indiMessages)
parent->ksw->statusBar()->changeItem( QString(valuXMLAtt(message)), 0);
}
void DeviceManager::sendNewText (INDI_P *pp)
{
INDI_E *lp;
fprintf(serverFP, "<newTextVector\n");
fprintf(serverFP, " device='%s'\n", pp->pg->dp->name.ascii());
fprintf(serverFP, " name='%s'\n>", pp->name.ascii());
for (lp = pp->el.first(); lp != NULL; lp = pp->el.next())
{
fprintf(serverFP, " <oneText\n");
fprintf(serverFP, " name='%s'>\n", lp->name.ascii());
fprintf(serverFP, " %s\n", lp->text.ascii());
fprintf(serverFP, " </oneText>\n");
}
fprintf