summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/devicemanager.h
blob: 53c9d78d0cac04cc84a444ded6e0a4dd3074e366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*  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
   
 */
 
 #ifndef DEVICEMANAGER_H
 #define DEVICEMANAGER_H
 
 #include "indielement.h"
 
 class INDIMenu;
 class INDI_P;
 class INDI_D;
 
 class QSocketNotifier;
 
 // INDI device manager
class DeviceManager : public QObject
{
   Q_OBJECT
   public:
   DeviceManager(INDIMenu *INDIparent, int inID);
   ~DeviceManager();

   INDIMenu *parent;

   QPtrList<INDI_D> indi_dev;

   int			mgrID;
   int			serverFD;
   FILE			*serverFP;
   LilXML		*XMLParser;
   QSocketNotifier 	*sNotifier;
   QString		host;
   QString		port;

   int dispatchCommand   (XMLEle *root, char errmsg[]);

   INDI_D *  addDevice   (XMLEle *dep , char errmsg[]);
   INDI_D *  findDev     (XMLEle *root, int  create, char errmsg[]);

   /*****************************************************************
   * Send to server
   ******************************************************************/
   void sendNewText    (INDI_P *pp);
   void sendNewNumber  (INDI_P *pp);
   void sendNewSwitch  (INDI_P *pp, int index);
   void startBlob (QString devName, QString propName, QString timestamp);
   void sendOneBlob(QString blobName, unsigned int blobSize, QString blobFormat, unsigned char * blobBuffer);
   void finishBlob();

   /*****************************************************************
   * Misc.
   ******************************************************************/
   int  delPropertyCmd (XMLEle *root, char errmsg[]);
   int  removeDevice   (QString devName, char errmsg[]);
   INDI_D *  findDev   (QString devName, char errmsg[]);

   int  messageCmd     (XMLEle *root, char errmsg[]);
   void checkMsg       (XMLEle *root, INDI_D *dp);
   void doMsg          (XMLEle *msg , INDI_D *dp);

   bool indiConnect    (QString inHost, QString inPort);

  public slots:
   void dataReceived();
   
  signals:
   void newDevice();

};

#endif