Commit e47d7441 authored by Matt Edman's avatar Matt Edman
Browse files

Add support for the NEWDESC control event.


svn:r722
parent d970d6c1
Loading
Loading
Loading
Loading
+4 −2
Changes for src/control/control.pri: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ HEADERS += $$PWD/torcontrol.h \
           $$PWD/streamevent.h \
           $$PWD/logevent.h \
           $$PWD/orconnevent.h \
           $$PWD/torsignal.h
           $$PWD/torsignal.h \
           $$PWD/newdescriptorevent.h

SOURCES += $$PWD/torcontrol.cpp \
           $$PWD/torprocess.cpp \
@@ -50,5 +51,6 @@ SOURCES += $$PWD/torcontrol.cpp \
           $$PWD/streamevent.cpp \
           $$PWD/logevent.cpp \
           $$PWD/orconnevent.cpp \
           $$PWD/torsignal.cpp
           $$PWD/torsignal.cpp \
           $$PWD/newdescriptorevent.cpp
+1 −0
Changes for src/control/eventtype.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ namespace CustomEventType {
  const int StreamEvent    = QEvent::User+2;
  const int LogEvent       = QEvent::User+3;
  const int OrConnEvent    = QEvent::User+4;
  const int NewDescriptorEvent = QEvent::User+5;
}

#endif
+43 −0
Changes for src/control/newdescriptorevent.cpp: 43 added lines, 0 removed lines.
Original line number Diff line number Diff line
/****************************************************************
 *  Vidalia is distributed under the following license:
 *
 *  Copyright (C) 2006,  Matt Edman, Justin Hipple
 *
 *  This program 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.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 *  Boston, MA  02110-1301, USA.
 ****************************************************************/

/** 
 * \file newdescriptorevent.cpp
 * \version $Id$
 */

#include "eventtype.h"
#include "newdescriptorevent.h"

/** Default constructor */
NewDescriptorEvent::NewDescriptorEvent(QStringList descList)
: QEvent((QEvent::Type)CustomEventType::NewDescriptorEvent)
{
  _descList = descList;
}

/** Returns the list of new descriptors available. */
QStringList
NewDescriptorEvent::descriptors()
{
  return _descList;
}
+48 −0
Changes for src/control/newdescriptorevent.h: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
/****************************************************************
 *  Vidalia is distributed under the following license:
 *
 *  Copyright (C) 2006,  Matt Edman, Justin Hipple
 *
 *  This program 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.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 *  Boston, MA  02110-1301, USA.
 ****************************************************************/

/** 
 * \file newdescriptorevent.h
 * \version $Id$
 */

#ifndef _NEWDESCRIPTOREVENT_H
#define _NEWDESCRIPTOREVENT_H

#include <QStringList>
#include <QEvent>


class NewDescriptorEvent : public QEvent
{
public:
  /** Default constructor */
  NewDescriptorEvent(QStringList descList);
  
  /** Returns the ID for this circuit */
  QStringList descriptors();
  
private:
  /** A list of new descriptors available. */
  QStringList _descList;
};

#endif
+18 −0
Changes for src/control/torevents.cpp: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ TorEvents::toString(TorEvent e)
    case Circuit:   event = "CIRC"; break;
    case Stream:    event = "STREAM"; break;
    case OrConn:    event = "ORCONN"; break;
    case NewDescriptor: event = "NEWDESC"; break;
    default: event = "UNKNOWN"; break;
  }
  return event;
@@ -143,6 +144,8 @@ TorEvents::toTorEvent(QString event)
    e = LogError;
  } else if (event == "ORCONN") {
    e = OrConn;
  } else if (event == "NEWDESC") {
    e = NewDescriptor;
  } else {
    e = Unknown;
  }
@@ -171,6 +174,7 @@ TorEvents::handleEvent(ControlReply reply)
      case Circuit:    handleCircuitStatus(line); break;
      case Stream:     handleStreamStatus(line); break;
      case OrConn:     handleOrConnStatus(line); break;
      case NewDescriptor: handleNewDescriptor(line); break;

      case LogDebug: 
      case LogInfo:
@@ -304,3 +308,17 @@ TorEvents::handleOrConnStatus(ReplyLine line)
  }
}

/** Handles a new descriptor event. The format for event messages of this type
 * is:
 *  
 *   "650" SP "NEWDESC" 1*(SP ServerID)
 */
void
TorEvents::handleNewDescriptor(ReplyLine line)
{
  QStringList descs = line.getMessage().split(" ");
  if (descs.size() > 0) {
    dispatch(NewDescriptor, new NewDescriptorEvent(descs));
  }
}
Loading