Skip to content
Browse files

This commit was manufactured by cvs2svn to create branch

'release-0-18-fixes'.

git-svn-id: http://svn.mythtv.org/svn/branches/release-0-18-fixes@6077 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information...
1 parent 5b0351d commit 0ef3ca5c3f59154651a8e896718fe6aa5053989d @jannau jannau committed Apr 15, 2005
Showing with 0 additions and 19,569 deletions.
  1. +0 −4 mfd/.cvsignore
  2. +0 −21 mfd/COPYING
  3. +0 −161 mfd/README
  4. +0 −3 mfd/clientlib/.cvsignore
  5. +0 −25 mfd/clientlib/README
  6. +0 −392 mfd/clientlib/audioclient.cpp
  7. +0 −45 mfd/clientlib/audioclient.h
  8. +0 −42 mfd/clientlib/clientlib.pro
  9. +0 −86 mfd/clientlib/discovered.cpp
  10. +0 −63 mfd/clientlib/discovered.h
  11. +0 −816 mfd/clientlib/discoverythread.cpp
  12. +0 −57 mfd/clientlib/discoverythread.h
  13. +0 −176 mfd/clientlib/events.cpp
  14. +0 −197 mfd/clientlib/events.h
  15. +0 −41 mfd/clientlib/mdcaprequest.cpp
  16. +0 −36 mfd/clientlib/mdcaprequest.h
  17. +0 −28 mfd/clientlib/mdcapresponse.cpp
  18. +0 −30 mfd/clientlib/mdcapresponse.h
  19. +0 −379 mfd/clientlib/mdnsd/1035.c
  20. +0 −99 mfd/clientlib/mdnsd/1035.h
  21. +0 −10 mfd/clientlib/mdnsd/Makefile
  22. +0 −13 mfd/clientlib/mdnsd/README
  23. +0 −770 mfd/clientlib/mdnsd/mdnsd.c
  24. +0 −101 mfd/clientlib/mdnsd/mdnsd.h
  25. +0 −145 mfd/clientlib/mdnsd/mhttp.c
  26. +0 −115 mfd/clientlib/mdnsd/mquery.c
  27. +0 −80 mfd/clientlib/mdnsd/sdtxt.c
  28. +0 −11 mfd/clientlib/mdnsd/sdtxt.h
  29. +0 −167 mfd/clientlib/mdnsd/xht.c
  30. +0 −29 mfd/clientlib/mdnsd/xht.h
  31. +0 −1,560 mfd/clientlib/metadataclient.cpp
  32. +0 −103 mfd/clientlib/metadataclient.h
  33. +0 −498 mfd/clientlib/metadatacollection.cpp
  34. +0 −96 mfd/clientlib/metadatacollection.h
  35. +0 −1,884 mfd/clientlib/mfdcontent.cpp
  36. +0 −139 mfd/clientlib/mfdcontent.h
  37. +0 −655 mfd/clientlib/mfdinstance.cpp
  38. +0 −102 mfd/clientlib/mfdinstance.h
  39. +0 −631 mfd/clientlib/mfdinterface.cpp
  40. +0 −116 mfd/clientlib/mfdinterface.h
  41. +0 −456 mfd/clientlib/pixmaps/album_pix.xpm
  42. +0 −281 mfd/clientlib/pixmaps/artist_pix.xpm
  43. +0 −344 mfd/clientlib/pixmaps/container_pix.xpm
  44. +0 −297 mfd/clientlib/pixmaps/edit_playlist_pix.xpm
  45. +0 −315 mfd/clientlib/pixmaps/edit_track_pix.xpm
  46. +0 −266 mfd/clientlib/pixmaps/genre_pix.xpm
  47. +0 −235 mfd/clientlib/pixmaps/new_playlist_pix.xpm
  48. +0 −131 mfd/clientlib/pixmaps/playlist_pix.xpm
  49. +0 −314 mfd/clientlib/pixmaps/track_pix.xpm
  50. +0 −62 mfd/clientlib/playlist.cpp
  51. +0 −57 mfd/clientlib/playlist.h
  52. +0 −279 mfd/clientlib/playlistchecker.cpp
  53. +0 −74 mfd/clientlib/playlistchecker.h
  54. +0 −29 mfd/clientlib/playlistentry.cpp
  55. +0 −39 mfd/clientlib/playlistentry.h
  56. +0 −117 mfd/clientlib/serviceclient.cpp
  57. +0 −68 mfd/clientlib/serviceclient.h
  58. +0 −392 mfd/configure
  59. +0 −2 mfd/mdcaplib/.cvsignore
  60. +0 −22 mfd/mdcaplib/README
  61. +0 −67 mfd/mdcaplib/markupcodes.cpp
  62. +0 −106 mfd/mdcaplib/markupcodes.h
  63. +0 −1,322 mfd/mdcaplib/mdcapinput.cpp
  64. +0 −85 mfd/mdcaplib/mdcapinput.h
  65. +0 −18 mfd/mdcaplib/mdcaplib.pro
  66. +0 −729 mfd/mdcaplib/mdcapoutput.cpp
  67. +0 −143 mfd/mdcaplib/mdcapoutput.h
  68. +0 −11 mfd/mfd.pro
  69. +0 −6 mfd/mfd/.cvsignore
  70. +0 −15 mfd/mfd/.qmake.internal.cache
  71. +0 −5 mfd/mfd/config.h
  72. +0 −327 mfd/mfd/dbcheck.cpp
  73. +0 −7 mfd/mfd/dbcheck.h
  74. +0 −128 mfd/mfd/logging.cpp
  75. +0 −56 mfd/mfd/logging.h
  76. +0 −210 mfd/mfd/main.cpp
  77. +0 −213 mfd/mfd/mdcaprequest.cpp
  78. +0 −75 mfd/mfd/mdcaprequest.h
  79. +0 −72 mfd/mfd/mdcapsession.cpp
  80. +0 −34 mfd/mfd/mdcapsession.h
  81. +0 −2,063 mfd/mfd/mdserver.cpp
  82. +0 −171 mfd/mfd/mdserver.h
Sorry, we could not display the entire diff because too many files (373) changed.
View
4 mfd/.cvsignore
@@ -1,4 +0,0 @@
-Makefile
-config.pro
-options.pro
-config.h
View
21 mfd/COPYING
@@ -1,21 +0,0 @@
-
- The mfd (Myth Frontend Daemon) is, unless otherwise noted (see below),
-distributed under the terms of the GPL, version 2 only. If you don't have a
-copy of the GPL, get one at:
-
- http://www.gnu.org/licenses/gpl.txt
-
- The mfd employs a plugin interface which allows runtime linking to other
-code. This interface is licensed under the terms of LGPL. If you don't have
-a copy of the LGPL, get one at:
-
- http://www.gnu.org/licenses/lgpl.txt
-
- Among the plugins that use this interface, the zeroconfig plugin is
-derived work from code originally covered under the Apple Public Source
-License (APSL) version 2. It is, therefore, distributed under the terms of
-the APSL version 2. A copy of that license can be found in:
-
- ./mfd/plugins/zeroconfig/apple/APPLE_LICENSE
-
-
View
161 mfd/README
@@ -1,161 +0,0 @@
- mfd - Myth Frontend Daemon
- Release 0.??
-
-
-GENERAL INFO
-------------
-
-INSTALL (see DEPENDENCIES):
-
- ./configure
- qmake
- make
- make install
- ldconfig
-
-RUN:
-
- to start it: mfd -l 10 (log with verbosity equal to 10)
- to stop it: mfdctl stop
-
- You can just CTRL-C the mfd and it will shut down cleanly. If it's in
-daemon mode, you'll need to use mfdctl stop.
-
-
-
-DEPENDENCIES
-------------
-
- The mfd essentially has all the dependencies of MythTV plus MythMusic
-and (probably by the time you read this) MythDVD. In addition, you will also
-need:
-
-LiveMedia Library
-http://www.live.com/liveMedia/
-
- Any reasonably recent version should be fine. There's a debian package
- called liblivemedia-dev, and almost certainly packages for other
- distributions as well. Note that this is not _strictly_ required (you
- can turn it off with ./configure --disable-rtsp), but is very, very
- highly recommended.
-
-FAAD2 library
-http://www.audiocoding.com/
-
- __NB__: As of March 5, 2004, you can build and install FAAD2 v2.0 final,
- but you must manually copy mp4ff_int_types.h from faad2/common/mp4ff/ to
- your usr/local/include/ directory.
-
- This is fairly annoying, but not insurmountable.
-
-
-OpenSLL
-
- Also required is openssl (for generating unique identifiers for content
- files). This should be included with just about any Linux distribution.
-
-
-OpenDAAP Library
-
- You'll also need libopendaap if you want to play iTunes content. Make
- _sure_ to get the right version. Also, make _sure_ you read the
- daapclient plugin README for further details
- (./mfd/plugins/daapclient/README).
-
-
-
-INFORMATION FOR DEVELOPERS
---------------------------
-
- The mfd is not terribly complicated. There is a core little object
-(called MFD) that main() creates and hands over control to. It creates a
-metadata server to be the holding pen for all metadata (a collection of
-MetadataContainers). It also creates a plugin manager. Plugins can either
-present their own (socket-based) interface to the world, or get passed
-commands that begin with a given token from the mfd. For example, the audio
-plugin has it's own interface, while the dummy plugin just uses the mfd's
-interface and asks for any string of command tokens that begin with the term
-"dummy". The former is called a "service", the latter a "capability".
-
-Every plugin (can! must?) run as a separate thread. They can and do create
-their own sub-threads. Most information they want to pass up to the mfd is
-send by QCustomEvents (see mfd_events.h/.cpp in mfdlib). If they need to
-describe metadata (appearance of, changes in), they get a pointer to the
-MetadataServer and make calls on it.
-
-The mfd itself speaks a protocol called mfdp (mfd protocol). This is a
-classic example of YAMUP (yet another made up protocol). The audio plugin
-speaks macp (myth audio control protocol ... which is also YAMUP). Most
-importantly, the metadata server embedded in the core mfd object speaks a
-protocol called mdcap (Myth Digital Content Access Protocol). This is what
-lets frontend clients figure what content a given mfd has on offer. See
-./mdcaplib/README for a few more details.
-
-Here's a list of client side mfdp commands (by the time you read this, it
-will probably be out of date). Note that you can play with these at a telnet
-prompt (e.g. telnet localhost 2342).
-
-
-hello Ask the mfd to say hello. Should send back "greetings".
-
-
-halt Make the mfd shut down and exit.
-quit " "
-shutdown " "
-
-
-dummy This just gets passed to the dummy plugin. It will
- respond with "dummy exists" (assuming the dummy plugin
- exists, which it should.) You can also send it the command
- "dummy die". It will then generate a FatalEvent, causing
- the plugin manager to unload it.
-
-
-reload Ask the mfd to make the plugin manager reload all plugins.
- This will send "restart" to every connected client and
- anything the plugins were in the process of doing will be
- shutdown and cleaned out. Normal clients should not do
- this.
-
-
-services list Ask the mfd to send "services found ... " messages to you
- listing all the services it is aware of. These are things
- that plugins do on their own sockets.
-
-capabilities list This is a list of first tokens that either the mfd itself
- or one of its plugins can handle via the mfd's socket
- interface. These obviously have the effect of increasing
- this list of client side commands (!).
-
-The following are commands that the mfd can send to any client **at any
-time**. That means your code (where "you" are a myth client developer) needs
-to be able to act appropriately:
-
-huh If you send something that the mfd (and/or its plugins)
- can't parse, you'll (probably?) get back "huh", followed
- by the set of tokens it didn't understand.
-
-bye Your socket connection is about to be closed because the
- mfd is exiting (user killed it, machine is shutting
- down, etc.)
-
-restart All the plugins are being killed and reloaded (mfd
- probably got a reload command). Anything you had going
- on (a video transcode, music playing, etc.) will get
- killed and cleaned up. The socket will stay open,
- however, so you can rebuild whatever you need to get
- back to where you were.
-
-fatal Some plugin had a fatal event (it freaked out and had to
- be unloaded). If it didn't happen to be (one of) the
- plugin(s) handling your requests, then nothing should
- change. However, it may well be that something you were
- expecting to happen will not.
-
-services found ... Some new service has been automagically discovered.
-
-services lost ... Some service that used to exist has gone away. You may
- have to update *lots* of internal data.
-
-capability foo If you send some commands beginning with the token foo,
- there is a plugin that will swallow them.
View
3 mfd/clientlib/.cvsignore
@@ -1,3 +0,0 @@
-Makefile
-libmfdclient.so.1.0.0
-moc_mfdinterface.cpp
View
25 mfd/clientlib/README
@@ -1,25 +0,0 @@
-
-libmfdclient - README
----------------------
-
- This is a library intended to simplify building client applications that
-can talk to a running mfd (or a whole bunch of 'em).
-
- It uses zeroconfig to find the mfd's. Please note, the code included in
-./mdnsd/ is originally licensed as GPL and/or BSD and/or other by the
-original author and copyright holder. The copy included here is licensed
-under the GPL version 2 only.
-
- Upon initialization, the client library exposes an interface object
-called an MfdInterface. This MfdInterface can then be queried to get
-information about MfdInstance objects. These instances of available mfd's on
-the network can further be queried to get metadata, ask for audio to be
-played, etc. Note that an mfd, and therefore an MfdInstace object can
-dissappear at any time. That's why the interface does not provide direct
-access to the MfdInstance objects themselves.
-
- The MfdInterface present a regular Qt object to the client programmer.
-Although threads are used internally to talk to various mfd plugins, the
-interface to the client developer is a single threaded application that runs
-in the Qt event loop. This (is intended to?) greatly simplify writing client
-GUI stuff.
View
392 mfd/clientlib/audioclient.cpp
@@ -1,392 +0,0 @@
-/*
- audioclient.cpp
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- client object to talk to an mfd's audio playing service
-
-*/
-
-#include <iostream>
-using namespace std;
-
-#include <qapplication.h>
-
-#include "audioclient.h"
-#include "events.h"
-#include "mfdinterface.h"
-
-AudioClient::AudioClient(
- MfdInterface *the_mfd,
- int an_mfd,
- const QString &l_ip_address,
- uint l_port
- )
- :ServiceClient(
- the_mfd,
- an_mfd,
- MFD_SERVICE_AUDIO_CONTROL,
- l_ip_address,
- l_port,
- "audio"
- )
-{
-}
-
-void AudioClient::playTrack(int container, int id)
-{
- QString command = QString("play item %1 %2 \n")
- .arg(container)
- .arg(id);
-
- client_socket_to_service->writeBlock(command.ascii(), command.length());
-}
-
-void AudioClient::playList(int container, int id, int index)
-{
- QString command = QString("play list %1 %2 %3 \n")
- .arg(container)
- .arg(id)
- .arg(index);
-
- client_socket_to_service->writeBlock(command.ascii(), command.length());
-}
-
-void AudioClient::stopAudio()
-{
- QString command = QString("stop \n");
- client_socket_to_service->writeBlock(command.ascii(), command.length());
-}
-
-void AudioClient::pauseAudio(bool y_or_n)
-{
- QString command;
- if(y_or_n)
- {
- command = QString("pause on \n");
- }
- else
- {
- command = QString("pause off \n");
- }
-
- client_socket_to_service->writeBlock(command.ascii(), command.length());
-}
-
-void AudioClient::seekAudio(int how_much)
-{
- QString command = QString("seek %1 \n").arg(how_much);
- client_socket_to_service->writeBlock(command.ascii(), command.length());
-}
-
-void AudioClient::nextAudio()
-{
- QString command = QString("next \n");
- client_socket_to_service->writeBlock(command.ascii(), command.length());
-}
-
-void AudioClient::prevAudio()
-{
- QString command = QString("prev \n");
- client_socket_to_service->writeBlock(command.ascii(), command.length());
-}
-
-void AudioClient::handleIncoming()
-{
- //
- // We're getting something about the state of audio play.
- //
-
- char in_buffer[2049];
-
- int amount_read = client_socket_to_service->readBlock(in_buffer, 2048);
- if(amount_read < 0)
- {
- cerr << "audioclient.o: error reading from service" << endl;
- return;
- }
- else if(amount_read == 0)
- {
- return;
- }
- else
- {
- in_buffer[amount_read] = '\0';
- QString incoming_text = QString(in_buffer);
-
- incoming_text.simplifyWhiteSpace();
-
- QStringList line_by_line = QStringList::split("\n", incoming_text);
-
- for(uint i = 0; i < line_by_line.count(); i++)
- {
- QStringList tokens = QStringList::split(" ", line_by_line[i]);
- parseFromAudio(tokens);
- }
- }
-
-}
-
-void AudioClient::parseFromAudio(QStringList &tokens)
-{
- if(tokens.count() < 1)
- {
- cerr << "audioclient.o: got no tokens to parse"
- << endl;
- return;
- }
-
- if(tokens[0] == "pause")
- {
- if(tokens.count() < 2)
- {
- cerr << "audioclient.o: got pause token, but no on or off"
- << endl;
- return;
- }
- if(tokens[1] == "on")
- {
- MfdAudioPausedEvent *ape = new MfdAudioPausedEvent(mfd_id, true);
- QApplication::postEvent(mfd_interface, ape);
- return;
- }
- else if(tokens[1] == "off")
- {
- MfdAudioPausedEvent *ape = new MfdAudioPausedEvent(mfd_id, false);
- QApplication::postEvent(mfd_interface, ape);
- return;
- }
- cerr << "audioclinet.cpp: don't understand these tokens: "
- << tokens.join(" ")
- << endl;
- return;
- }
-
- if(tokens[0] == "stop")
- {
- MfdAudioStoppedEvent *ase = new MfdAudioStoppedEvent(mfd_id);
- QApplication::postEvent(mfd_interface, ase);
- return;
- }
-
- if(tokens[0] == "playing")
- {
- if(tokens.count() < 9)
- {
- cerr << "audio server seems to be playing, but it's not "
- << "sending the correct number of tokens"
- << endl;
- return;
- }
-
- MfdAudioPlayingEvent *ape = new MfdAudioPlayingEvent(
- mfd_id,
- tokens[1].toInt(),
- tokens[2].toInt(),
- tokens[3].toInt(),
- tokens[4].toInt(),
- tokens[5].toInt(),
- tokens[6].toInt(),
- tokens[7].toInt(),
- tokens[8].toInt()
- );
- QApplication::postEvent(mfd_interface, ape);
- return;
- }
-
- cerr << "getting tokens from audio server I don't understand: "
- << tokens.join(" ")
- << endl;
-}
-
-void AudioClient::executeCommand(QStringList new_command)
-{
- if(new_command.count() < 1)
- {
- cerr << "audioclient.o: asked to executeCommand(), "
- << "but got no commands."
- << endl;
- return;
- }
-
- if(new_command[0] == "play")
- {
- //
- // Make sure we have enough tokens for a "play" command
- //
-
- if(new_command.count() < 5)
- {
- cerr << "audioclient.o: asked to play audio, but not "
- << "enough tokens provided to know what to play."
- << endl;
- return;
- }
-
- //
- // Convert the string tokens to useful variables
- //
-
- bool ok = true;
-
- int container = new_command[1].toInt(&ok);
- if(container < 0 || !ok)
- {
- cerr << "audioclient.o: error converting play command's "
- << "container token."
- << endl;
- return;
- }
-
- int type = new_command[2].toInt(&ok);
- if(type < 1 || type > 2 || !ok)
- {
- cerr << "audioclient.o: error converting play command's "
- << "type token."
- << endl;
- return;
- }
-
- int which_id = new_command[3].toInt(&ok);
- if(which_id < 0 || !ok)
- {
- cerr << "audioclient.o: error converting play command's "
- << "which_id token."
- << endl;
- return;
- }
-
- int index = new_command[4].toInt(&ok);
- if(index < 0 || !ok)
- {
- cerr << "audioclient.o: error converting play command's "
- << "index token."
- << endl;
- return;
- }
-
- //
- // Either basic metadata item (type = 1) or an entry in a playlist (type = 2)
- //
-
- if(type == 1)
- {
- playTrack(container, which_id);
- }
- else if(type == 2)
- {
- playList(container, which_id, index);
- }
-
- }
- else if(new_command[0] == "stop")
- {
- //
- // Stop the audio
- //
-
- stopAudio();
- }
- else if(new_command[0] == "pause")
- {
- //
- // Turn audio pause on or off
- //
-
- if(new_command.count() < 2)
- {
- cerr << "audioclient.o: pause is a useless command "
- << "unless you add \"on\" or \"off\"."
- << endl;
- return;
- }
-
- if(new_command[1] == "on")
- {
- pauseAudio(true);
- }
- else if(new_command[1] == "off")
- {
- pauseAudio(false);
- }
- else
- {
- cerr << "audioclient.o: got pause command with "
- << "neither \"on\" nor \"off\"."
- << endl;
- }
- }
- else if(new_command[0] == "seek")
- {
- //
- // Seek some number of seconds
- //
-
- if(new_command.count() < 2)
- {
- cerr << "audioclient.o: seek is a useless command "
- << "without amount."
- << endl;
- return;
- }
-
- bool ok = true;
- int amount = new_command[1].toInt(&ok);
- if(!ok)
- {
- cerr << "audioclient.o: could not parse seek amount"
- << endl;
- return;
- }
-
- seekAudio(amount);
- }
- else if(new_command[0] == "next")
- {
- //
- // Next track
- //
-
- nextAudio();
- }
- else if(new_command[0] == "prev")
- {
- //
- // Next track
- //
-
- prevAudio();
- }
- else if(new_command[0] == "status")
- {
- //
- // Send status
- //
-
- askForStatus();
- }
- else
- {
- cerr << "audioclient.o: I don't understand this "
- << "command: \""
- << new_command.join(" ")
- << "\""
- << endl;
- }
-
-}
-
-void AudioClient::askForStatus()
-{
- QString command = QString("status \n");
- client_socket_to_service->writeBlock(command.ascii(), command.length());
-}
-
-AudioClient::~AudioClient()
-{
-}
-
-
-
-
View
45 mfd/clientlib/audioclient.h
@@ -1,45 +0,0 @@
-#ifndef AUDIOCLIENT_H_
-#define AUDIOCLIENT_H_
-/*
- audioclient.h
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- client object to talk to an mfd's audio playing service
-
-*/
-
-#include <qstringlist.h>
-
-#include "serviceclient.h"
-
-class AudioClient : public ServiceClient
-{
-
- public:
-
- AudioClient(
- MfdInterface *the_mfd,
- int an_mfd,
- const QString &l_ip_address,
- uint l_port
- );
-
-
- void playTrack(int container, int id);
- void playList(int container, int id, int index);
- void stopAudio();
- void pauseAudio(bool y_or_n);
- void seekAudio(int how_much);
- void nextAudio();
- void prevAudio();
- void handleIncoming();
- void parseFromAudio(QStringList &tokens);
- void executeCommand(QStringList new_command);
- void askForStatus();
- ~AudioClient();
-
-};
-
-#endif
View
42 mfd/clientlib/clientlib.pro
@@ -1,42 +0,0 @@
-include (../settings.pro)
-
-!exists(../config.pro ) {
- error(Missing config.pro: please run the configure script)
-}
-
-include (../options.pro)
-
-TEMPLATE = lib
-CONFIG += thread dll
-TARGET = mfdclient
-
-target.path = $${PREFIX}/lib
-INSTALLS = target
-
-HEADERS += mfdinterface.h discoverythread.h mfdinstance.h \
- ./mdnsd/mdnsd.h ./mdnsd/1035.h discovered.h \
- events.h serviceclient.h audioclient.h metadataclient.h \
- ../mfdlib/httpoutrequest.h \
- ../mfdlib/httpinresponse.h \
- ../mfdlib/httpheader.h \
- ../mfdlib/httpgetvar.h \
- mdcaprequest.h mdcapresponse.h metadatacollection.h ../mfdlib/metadata.h \
- playlist.h playlistentry.h mfdcontent.h playlistchecker.h
-
-SOURCES += mfdinterface.cpp discoverythread.cpp mfdinstance.cpp \
- ./mdnsd/mdnsd.c ./mdnsd/1035.c discovered.cpp \
- events.cpp serviceclient.cpp audioclient.cpp metadataclient.cpp \
- ../mfdlib/httpoutrequest.cpp \
- ../mfdlib/httpinresponse.cpp \
- ../mfdlib/httpheader.cpp \
- ../mfdlib/httpgetvar.cpp \
- mdcaprequest.cpp mdcapresponse.cpp metadatacollection.cpp ../mfdlib/metadata.cpp \
- playlist.cpp playlistentry.cpp mfdcontent.cpp playlistchecker.cpp
-
-inc.path = $${PREFIX}/include/mfdclient/
-inc.files = mfdinterface.h mfdcontent.h ../mfdlib/metadata.h playlist.h playlistentry.h
-
-LIBS += -L../mdcaplib -lmdcap -Wl,--export-dynamic
-
-INSTALLS += inc
-
View
86 mfd/clientlib/discovered.cpp
@@ -1,86 +0,0 @@
-/*
- discovered.cpp
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- Small object to keep track of the availability of mfd's
-
-*/
-
-
-#include <unistd.h>
-#include <iostream>
-using namespace std;
-#include <netdb.h>
-
-#include "discovered.h"
-
-DiscoveredMfd::DiscoveredMfd(QString l_full_service_name)
-{
- full_service_name = l_full_service_name;
- hostname = "";
- port_resolved = false;
- ip_resolved = false;
- time_to_live = 0;
- client_socket_to_mfd = NULL;
- port = 0;
- address = "";
-}
-
-int DiscoveredMfd::getSocket()
-{
- if(client_socket_to_mfd)
- {
- return client_socket_to_mfd->socket();
- }
- return -1;
-}
-
-bool DiscoveredMfd::connect()
-{
-
-
- QHostAddress this_address;
-
- if(!this_address.setAddress(getAddress()))
- {
- cerr << "discovered.o: can't set host address" << endl;
- return false;
- }
-
- client_socket_to_mfd = new QSocketDevice(QSocketDevice::Stream);
- client_socket_to_mfd->setBlocking(false);
-
- int connect_tries = 0;
-
- while(! (client_socket_to_mfd->connect(this_address, port)))
- {
- //
- // We give this a few attempts. It can take a few on non-blocking sockets.
- //
-
- ++connect_tries;
- if(connect_tries > 10)
- {
- cerr << "could not connect to mfd on \""
- << hostname
- << "\""
- << endl;
-
- return false;
- }
- usleep(3000);
- }
-
- return true;
-}
-
-DiscoveredMfd::~DiscoveredMfd()
-{
- if(client_socket_to_mfd)
- {
- delete client_socket_to_mfd;
- client_socket_to_mfd = NULL;
- }
-}
View
63 mfd/clientlib/discovered.h
@@ -1,63 +0,0 @@
-#ifndef DISCOVERED_H_
-#define DISCOVERED_H_
-/*
- discovered.h
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- Small object to keep track of the availability of mfd's
-
-*/
-
-#include <qstring.h>
-#include <qsocketdevice.h>
-
-
-class DiscoveredMfd
-{
-
- public:
-
- DiscoveredMfd(QString l_full_service_name);
- ~DiscoveredMfd();
-
- bool connect();
-
- QString getFullServiceName(){return full_service_name;}
-
- void setTimeToLive(int an_int){time_to_live = an_int;}
- int getTimeToLive(){return time_to_live;}
-
- bool isPortResolved(){return port_resolved;}
- void isPortResolved(bool y_or_n){port_resolved = y_or_n;}
-
- bool isIpResolved(){return ip_resolved;}
- void isIpResolved(bool y_or_n){ip_resolved = y_or_n;}
-
- QString getHostName(){return hostname;}
- void setHostName(QString a_host){hostname = a_host;}
-
- QString getAddress(){return address;}
- void setAddress(QString an_address){ address = an_address;}
-
- int getPort(){return port;}
- void setPort(int a_port){port = a_port;}
-
- int getSocket();
- QSocketDevice* getSocketDevice(){return client_socket_to_mfd;}
-
- private:
-
- QString address;
- QString full_service_name;
- QString hostname;
- bool port_resolved;
- bool ip_resolved;
- int time_to_live;
- int port;
- QSocketDevice *client_socket_to_mfd;
-
-};
-
-#endif
View
816 mfd/clientlib/discoverythread.cpp
@@ -1,816 +0,0 @@
-/*
- discoverythread.cpp
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- Little thread that keeps looking for (dis)appearance of mfd's
-
-*/
-
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <iostream>
-using namespace std;
-
-#include <qapplication.h>
-
-#include "discoverythread.h"
-#include "events.h"
-
-//
-// C callback from mdnsd stuff
-//
-
-extern "C" int callbackAnswer(mdnsda a, void *arg)
-{
- DiscoveryThread *discovery_thread = (DiscoveryThread *)arg;
-
- discovery_thread->handleMdnsdCallback(a);
-
- return 0;
-}
-
-
-
-
-DiscoveryThread::DiscoveryThread(MfdInterface *the_interface)
-{
- //
- // Get a pointer to the main MfdInterface objects so we can send it
- // events when mfd's appear or disappear
- //
-
- mfd_interface = the_interface;
-
- //
- // These get initialized in run()
- //
-
- mdns_daemon = NULL;
- mdns_ipaddr_daemon = NULL;
-
-
- //
- // By default, run
- //
-
- keep_going = true;
-
- //
- // Create a u shaped pipe so others can wake us out of a select
- //
-
-
- if(pipe(u_shaped_pipe) < 0)
- {
- warning("could not create a u shaped pipe");
- }
-
- //
- // Create our (empty) list of discovered mfd's
- //
-
- discovered_mfds = new QPtrList<DiscoveredMfd>;
- discovered_mfds->setAutoDelete(true);
-
-}
-
-void DiscoveryThread::run()
-{
-
- //
- // A lot of this is based on the mquery example in mdnsd
- //
-
- struct message m;
- unsigned long int ip;
- unsigned short int port;
- int bsize, ssize = sizeof(struct sockaddr_in);
- unsigned char buf[MAX_PACKET_LEN];
- struct sockaddr_in from, to;
-
-
- //
- // Create the main mdsnd process. I have no idea what either of these
- // parameters are supposed to mean.
- //
-
- mdns_daemon = mdnsd_new(1,1000);
-
- //
- // Create a separate one just to do IP address lookups. Why? Well, if
- // you try to do IP lookups with just the "main" mdns_daemon, there
- // always seem to be timing issues (ie. doesn't work properly)
- //
-
- mdns_ipaddr_daemon = mdnsd_new(1, 1000);
-
-
- //
- // Get a multicast socket for the main mdns daemon
- //
-
-
- int multicast_socket = createMulticastSocket();
-
- if( multicast_socket < 1)
- {
- mdnsd_shutdown(mdns_daemon);
- mdnsd_free(mdns_daemon);
- mdns_daemon = NULL;
- cerr << "discoverythread.o: could not create multicast socket" << endl;
- return;
- }
-
- //
- // Get a multicast socket for the ip address mdns daemon
- //
-
-
- int ipaddr_socket = createMulticastSocket();
-
- if( ipaddr_socket < 1)
- {
- mdnsd_shutdown(mdns_daemon);
- mdnsd_free(mdns_daemon);
- mdns_daemon = NULL;
-
- mdnsd_shutdown(mdns_ipaddr_daemon);
- mdnsd_free(mdns_ipaddr_daemon);
- mdns_ipaddr_daemon = NULL;
-
- cerr << "discoverythread.o: could not create multicast socket" << endl;
- return;
- }
-
- //
- // We watch only for mfdp services, cause once we've found an mfd, we
- // can query it directly about what services it has
- //
-
- mdnsd_query(mdns_daemon,"_mfdp._tcp.local.", QTYPE_PTR, callbackAnswer, this);
-
- //
- // Go to work
- //
-
- while(keep_going)
- {
- fd_set fds;
- int nfds = 0;
- FD_ZERO(&fds);
-
- //
- // Set up for select() to watch the multicast socket
- //
-
- FD_SET(multicast_socket,&fds);
- if(nfds <= multicast_socket)
- {
- nfds = multicast_socket + 1;
- }
-
- //
- // Set up for select() to watch the multicast ipaddress socket
- //
-
- FD_SET(ipaddr_socket,&fds);
- if(nfds <= ipaddr_socket)
- {
- nfds = ipaddr_socket + 1;
- }
-
- //
- // Add every mfd we are already connected to
- //
-
- QPtrListIterator<DiscoveredMfd> it( *discovered_mfds );
- DiscoveredMfd *an_mfd;
- while ( (an_mfd = it.current()) != 0 )
- {
- ++it;
- if(an_mfd->isIpResolved())
- {
- int mfd_socket = an_mfd->getSocket();
- if(mfd_socket > 0)
- {
- FD_SET(mfd_socket,&fds);
- if(nfds <= mfd_socket)
- {
- nfds = mfd_socket + 1;
- }
- }
- else
- {
- cerr << "discoverythread.o: discovered mfd object said "
- << "it was resolved, but has bad socket"
- << endl;
- }
- }
- }
-
- //
- // Add the control pipe
- //
-
- FD_SET(u_shaped_pipe[0], &fds);
- if(nfds <= u_shaped_pipe[0])
- {
- nfds = u_shaped_pipe[0] + 1;
- }
-
-
- //
- // Sleep as long as mdnsd tells us to
- //
-
- struct timeval *tv;
- tv = mdnsd_sleep(mdns_daemon);
-
- struct timeval *another_tv;
- another_tv = mdnsd_sleep(mdns_ipaddr_daemon);
-
- //
- // Sit in select until something happens
- //
-
- int result = 0;
- if(another_tv->tv_sec * 1000 + another_tv->tv_usec < tv->tv_sec * 1000 + tv->tv_usec)
- {
- result = select(nfds,&fds,NULL,NULL,another_tv);
- }
- else
- {
- result = select(nfds,&fds,NULL,NULL,tv);
- }
-
- if(result < 0)
- {
- cerr << "discoverythread.o: got an error on select (?), "
- << "which is far from a good thing"
- << endl;
- }
-
- //
- // In case data came in on out u_shaped_pipe, clean it out
- //
-
- if(FD_ISSET(u_shaped_pipe[0], &fds))
- {
- u_shaped_pipe_mutex.lock();
- char read_back[2049];
- read(u_shaped_pipe[0], read_back, 2048);
- u_shaped_pipe_mutex.unlock();
- }
-
- //
- // If something came in any of our mfd sockets, clean them out
- //
-
- QPtrListIterator<DiscoveredMfd> clean_it( *discovered_mfds );
- DiscoveredMfd *a_mfd;
- while ( (a_mfd = clean_it.current()) != 0 )
- {
- ++clean_it;
- if(a_mfd->isIpResolved())
- {
- int mfd_socket = a_mfd->getSocket();
- if(mfd_socket > 0)
- {
- if(FD_ISSET(mfd_socket, &fds))
- {
- char read_back[2049];
- read(mfd_socket, read_back, 2048);
- }
- }
- }
- }
-
-
-
- if(FD_ISSET(multicast_socket,&fds))
- {
- while((bsize = recvfrom(
- multicast_socket,
- buf,
- MAX_PACKET_LEN,
- 0,
- (struct sockaddr*)&from,
- (socklen_t *)&ssize)
- ) > 0)
- {
- bzero(&m,sizeof(struct message));
- message_parse(&m,buf);
- mdnsd_in(
- mdns_daemon,
- &m,
- (unsigned long int)from.sin_addr.s_addr,
- from.sin_port
- );
- }
- if(bsize < 0 && errno != EAGAIN)
- {
- printf("can't read socket %d: %s\n",errno,strerror(errno));
- //return 1;
- }
- }
- while(mdnsd_out(mdns_daemon,&m,&ip,&port))
- {
- bzero(&to, sizeof(to));
- to.sin_family = AF_INET;
- to.sin_port = port;
- to.sin_addr.s_addr = ip;
- if(
- sendto(
- multicast_socket,
- message_packet(&m),
- message_packet_len(&m),
- 0,
- (struct sockaddr *)&to,
- sizeof(struct sockaddr_in)
- )
- != message_packet_len(&m)
- )
- {
- printf("can't write to socket: %s\n",strerror(errno));
- //return 1;
- }
- }
-
- if(FD_ISSET(ipaddr_socket,&fds))
- {
- while((bsize = recvfrom(
- ipaddr_socket,
- buf,
- MAX_PACKET_LEN,
- 0,
- (struct sockaddr*)&from,
- (socklen_t *)&ssize)
- ) > 0)
- {
- bzero(&m,sizeof(struct message));
- message_parse(&m,buf);
- mdnsd_in(
- mdns_ipaddr_daemon,
- &m,
- (unsigned long int)from.sin_addr.s_addr,
- from.sin_port
- );
- }
- if(bsize < 0 && errno != EAGAIN)
- {
- printf("can't read socket %d: %s\n",errno,strerror(errno));
- //return 1;
- }
- }
- while(mdnsd_out(mdns_ipaddr_daemon,&m,&ip,&port))
- {
- bzero(&to, sizeof(to));
- to.sin_family = AF_INET;
- to.sin_port = port;
- to.sin_addr.s_addr = ip;
- if(
- sendto(
- ipaddr_socket,
- message_packet(&m),
- message_packet_len(&m),
- 0,
- (struct sockaddr *)&to,
- sizeof(struct sockaddr_in)
- )
- != message_packet_len(&m)
- )
- {
- printf("can't write to socket: %s\n",strerror(errno));
- //return 1;
- }
- }
-
-
- //
- // Check if any of our mfd's went away without removing themselves
- // from mDNS (ie. someone hit ctrl-c)
- //
-
- cleanDeadMfds();
- }
-
- //
- // Free up the mdnsd stuff
- //
-
- mdnsd_shutdown(mdns_daemon);
- mdnsd_free(mdns_daemon);
- mdns_daemon = NULL;
-
- mdnsd_shutdown(mdns_ipaddr_daemon);
- mdnsd_free(mdns_ipaddr_daemon);
- mdns_ipaddr_daemon = NULL;
-
- close(multicast_socket);
- close(ipaddr_socket);
-}
-
-int DiscoveryThread::createMulticastSocket()
-{
- int s, flag = 1, ittl = 255;
- struct sockaddr_in in;
- struct ip_mreq mc;
- char ttl = 255;
-
- bzero(&in, sizeof(in));
- in.sin_family = AF_INET;
- in.sin_port = htons(5353);
- in.sin_addr.s_addr = 0;
-
- if((s = socket(AF_INET,SOCK_DGRAM,0)) < 0)
- {
- return 0;
- }
-
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&flag, sizeof(flag));
- if(bind(s,(struct sockaddr*)&in,sizeof(in))) { close(s); return 0; }
-
- mc.imr_multiaddr.s_addr = inet_addr("224.0.0.251");
- mc.imr_interface.s_addr = htonl(INADDR_ANY);
- setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc, sizeof(mc));
- setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
- setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ittl, sizeof(ittl));
-
- flag = fcntl(s, F_GETFL, 0);
- flag |= O_NONBLOCK;
- fcntl(s, F_SETFL, flag);
-
- return s;
-
-}
-
-void DiscoveryThread::stop()
-{
- keep_going_mutex.lock();
- keep_going = false;
- keep_going_mutex.unlock();
- wakeUp();
-}
-
-void DiscoveryThread::wakeUp()
-{
- //
- // Tell the main thread to wake up by sending some data to ourselves on
- // our u_shaped_pipe. This may seem odd. It isn't.
- //
-
- u_shaped_pipe_mutex.lock();
- write(u_shaped_pipe[1], "wakeup\0", 7);
- u_shaped_pipe_mutex.unlock();
-}
-
-void DiscoveryThread::handleMdnsdCallback(mdnsda answer)
-{
- int now;
-
- if(answer->ttl == 0)
- {
- now = 0;
- }
- else
- {
- now = answer->ttl - time(0);
- }
-
- if(answer->type == QTYPE_PTR)
- {
- //
- // QTYPE_PTR answers tell us about the appearance and disapperance
- // of basic services without those services being resolved to
- // IP:port pairs.
- //
-
-
- //
- // See if we already have data about this service
- //
-
- QPtrListIterator<DiscoveredMfd> it( *discovered_mfds );
- DiscoveredMfd *which_one = NULL;
- DiscoveredMfd *an_mfd;
- while ( (an_mfd = it.current()) != 0 )
- {
- ++it;
- if(an_mfd->getFullServiceName() == QString((char *)answer->rdname))
- {
- which_one = an_mfd;
- break;
- }
- }
-
- if(which_one)
- {
- which_one->setTimeToLive(now);
- }
- else if(now > 0)
- {
- DiscoveredMfd *new_discovered_mfd
- = new DiscoveredMfd(QString( (char *)answer->rdname));
- new_discovered_mfd->setTimeToLive(now);
-
- discovered_mfds->append(new_discovered_mfd);
-
- //
- // Since this is new, we want to send out a query to get the
- // resolved ip and port of this service
- //
-
- if(mdns_daemon)
- {
- mdnsd_query(
- mdns_daemon,
- (char *)answer->rdname,
- QTYPE_SRV,
- callbackAnswer,
- this
- );
-
- }
- else
- {
- cerr << "discoverythread.o: how the hell did you get "
- << "here without an mdnds_daemon ?"
- << endl;
- }
- }
-
- //
- // Anything with a time to live of 0 is dead.
- //
-
- QPtrListIterator<DiscoveredMfd> dead_it( *discovered_mfds );
- DiscoveredMfd *dead_mfd = NULL;
- while ( (dead_mfd = dead_it.current()) != 0 )
- {
- if(dead_mfd->getTimeToLive() < 1 && dead_mfd->isIpResolved())
- {
- MfdDiscoveryEvent *de = new
- MfdDiscoveryEvent(
- false,
- dead_mfd->getFullServiceName(),
- dead_mfd->getHostName(),
- dead_mfd->getAddress(),
- dead_mfd->getPort()
- );
- QApplication::postEvent( mfd_interface, de );
- discovered_mfds->remove(dead_mfd);
- }
- else
- {
- ++dead_it;
- }
- }
-
-
- }
- else if(answer->type == QTYPE_SRV)
- {
-
- //
- // A QTYPE_SRV answer is giving us resolved host name and port for
- // a service (but not yet an ip address)
- //
-
- //
- // Find the service in question
- //
-
- QPtrListIterator<DiscoveredMfd> it( *discovered_mfds );
- DiscoveredMfd *which_one = NULL;
- DiscoveredMfd *an_mfd;
- while ( (an_mfd = it.current()) != 0 )
- {
- ++it;
- if(an_mfd->getFullServiceName() == QString((char *)answer->name))
- {
- which_one = an_mfd;
- break;
- }
- }
- if(which_one)
- {
- if(!which_one->isPortResolved())
- {
- which_one->setHostName(QString((char *) answer->rdname).section('.',0,0));
- which_one->setPort(answer->srv.port);
- which_one->isPortResolved(true);
- }
- if(!which_one->isIpResolved())
- {
- //
- // Ask mdsnd for the actual ip address for this hostname
- // (no, we can't just ask DNS)
- //
-
- QString ip_address_question = QString("%1.local.")
- .arg(which_one->getHostName());
-
-
- mdnsd_query(
- mdns_ipaddr_daemon,
- (char *) ip_address_question.ascii(),
- QTYPE_A,
- callbackAnswer,
- this
- );
- }
- }
- else
- {
- cerr << "discoverythread.o: got an mdns QTYPE_SRV response that I never asked for"
- << endl;
- }
- }
- else if(answer->type == QTYPE_A)
- {
- in_addr address;
- address.s_addr = answer->ip;
-
- //
- // For some obscure "let's not conflict with something" sort of
- // reason (I think), ip address comes in backwards.
- //
-
- QString backwards_dot_quad = QString(inet_ntoa(address));
-
- QString ip1 = backwards_dot_quad.section(".", 3, 3);
- QString ip2 = backwards_dot_quad.section(".", 2, 2);
- QString ip3 = backwards_dot_quad.section(".", 1, 1);
- QString ip4 = backwards_dot_quad.section(".", 0, 0);
-
- QString dot_quad_address = QString("%1.%2.%3.%4")
- .arg(ip1)
- .arg(ip2)
- .arg(ip3)
- .arg(ip4);
-
-
- QString hostname = QString((char *)answer->name).section(".", 0, 0);
-
- //
- // See if any of my discovered mfd objects are waiting for an ip
- // address
- //
-
- QPtrListIterator<DiscoveredMfd> it( *discovered_mfds );
- DiscoveredMfd *which_one = NULL;
- DiscoveredMfd *an_mfd;
- while ( (an_mfd = it.current()) != 0 )
- {
- ++it;
-
- if(an_mfd->getHostName() == QString((char *)answer->name).section(".", 0, 0))
- {
- which_one = an_mfd;
- break;
- }
- }
- if(which_one)
- {
- if(which_one->isPortResolved() && !which_one->isIpResolved())
- {
- which_one->setAddress(dot_quad_address);
- which_one->isIpResolved(true);
-
- //
- // Now we can try to connect
- //
-
- if(which_one->connect())
- {
- MfdDiscoveryEvent *de = new
- MfdDiscoveryEvent(
- true,
- which_one->getFullServiceName(),
- which_one->getHostName(),
- which_one->getAddress(),
- which_one->getPort()
- );
- QApplication::postEvent(mfd_interface, de);
- }
- else
- {
- cerr << "discoverythread.o: found an mfd but could "
- << "not connect to it"
- << endl;
- discovered_mfds->remove(which_one);
- }
- }
- }
- else
- {
- cerr << "discoverythread.cpp: getting mdns host->ip answers that I "
- << "never asked for"
- << endl;
- }
- }
- else
- {
- cerr << "discoverythread.o: gettting mdnsd answer types I don't understand"
- << endl;
- }
-
- // answer = mdnsd_list();
-}
-
-void DiscoveryThread::cleanDeadMfds()
-{
- //
- // This method has nothing to do with zeroconfig, it just looks to see
- // if the client to mfd has gone away (ie. mfd got ctrl-c's,
- // segfaulted, etc.)
- //
-
- QPtrListIterator<DiscoveredMfd> it( *discovered_mfds );
- DiscoveredMfd *an_mfd = NULL;
- while ( (an_mfd = it.current()) != 0 )
- {
- if(an_mfd->isIpResolved())
- {
- if(an_mfd->getSocket() < 1)
- {
- //
- //
- //
-
- MfdDiscoveryEvent *de = new
- MfdDiscoveryEvent(
- false,
- an_mfd->getFullServiceName(),
- an_mfd->getHostName(),
- an_mfd->getAddress(),
- an_mfd->getPort()
- );
- QApplication::postEvent(mfd_interface, de);
- discovered_mfds->remove(it);
- }
- else
- {
- bool still_there = true;
- QSocketDevice *the_socket = an_mfd->getSocketDevice();
- if(the_socket)
- {
- if(the_socket->waitForMore(30, &still_there) < 1)
- {
- if(!still_there)
- {
- MfdDiscoveryEvent *de = new
- MfdDiscoveryEvent(
- false,
- an_mfd->getFullServiceName(),
- an_mfd->getHostName(),
- an_mfd->getAddress(),
- an_mfd->getPort()
- );
- QApplication::postEvent(mfd_interface, de);
- discovered_mfds->remove(it);
- }
- else
- {
- ++it;
- }
- }
- else
- {
- ++it;
- }
- }
- else
- {
- cerr << "discoverythread.o: oh crap, "
- << "logical is disintegrating"
- << endl;
- }
- }
- }
- else
- {
- ++it;
- }
- }
-
-}
-
-DiscoveryThread::~DiscoveryThread()
-{
- if(discovered_mfds)
- {
- discovered_mfds->clear();
- delete discovered_mfds;
- discovered_mfds = NULL;
- }
-}
-
-
View
57 mfd/clientlib/discoverythread.h
@@ -1,57 +0,0 @@
-#ifndef DISCOVERYTHREAD_H_
-#define DISCOVERYTHREAD_H_
-/*
- discoverythread.h
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- Little thread that keeps looking for (dis)appearance of mfd's
-
-*/
-
-#include <unistd.h>
-
-#include <qthread.h>
-#include <qmutex.h>
-#include <qptrlist.h>
-
-#include "mfdinterface.h"
-#include "mdnsd/mdnsd.h"
-#include "discovered.h"
-
-
-
-class DiscoveryThread : public QThread
-{
-
- public:
-
- DiscoveryThread(MfdInterface *the_interface);
- ~DiscoveryThread();
-
- void run();
- void stop();
- void wakeUp();
- int createMulticastSocket();
- void handleMdnsdCallback(mdnsda answer);
- void cleanDeadMfds();
-
-
- private:
-
- QMutex keep_going_mutex;
- bool keep_going;
-
- QMutex u_shaped_pipe_mutex;
- int u_shaped_pipe[2];
-
- mdnsd mdns_daemon;
- mdnsd mdns_ipaddr_daemon;
-
- QPtrList<DiscoveredMfd> *discovered_mfds;
-
- MfdInterface *mfd_interface;
-};
-
-#endif
View
176 mfd/clientlib/events.cpp
@@ -1,176 +0,0 @@
-/*
- events.cpp
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- events that get passed to mfdinterface
-
-*/
-
-#include "events.h"
-
-MfdDiscoveryEvent::MfdDiscoveryEvent(
- bool is_it_lost_or_found,
- const QString &a_name,
- const QString &a_hostname,
- const QString &an_ip_address,
- int a_port
- )
- :QCustomEvent(MFD_CLIENTLIB_EVENT_DISCOVERY)
-{
- lost_or_found = is_it_lost_or_found;
- name = a_name;
- hostname = a_hostname;
- ip_address = an_ip_address;
- port = a_port;
-}
-
-bool MfdDiscoveryEvent::getLostOrFound()
-{
- return lost_or_found;
-}
-
-QString MfdDiscoveryEvent::getName()
-{
- return name;
-}
-
-QString MfdDiscoveryEvent::getHost()
-{
- return hostname;
-}
-
-QString MfdDiscoveryEvent::getAddress()
-{
- return ip_address;
-}
-
-int MfdDiscoveryEvent::getPort()
-{
- return port;
-}
-
-/*
----------------------------------------------------------------------
-*/
-
-MfdAudioPausedEvent::MfdAudioPausedEvent(
- int which_mfd,
- bool on_or_off
- )
- :QCustomEvent(MFD_CLIENTLIB_EVENT_AUDIOPAUSE)
-
-{
- mfd_id = which_mfd;
- paused_or_not = on_or_off;
-}
-
-int MfdAudioPausedEvent::getMfd()
-{
- return mfd_id;
-}
-
-bool MfdAudioPausedEvent::getPaused()
-{
- return paused_or_not;
-}
-
-/*
----------------------------------------------------------------------
-*/
-
-MfdAudioStoppedEvent::MfdAudioStoppedEvent(int which_mfd)
- :QCustomEvent(MFD_CLIENTLIB_EVENT_AUDIOSTOP)
-
-{
- mfd_id = which_mfd;
-}
-
-int MfdAudioStoppedEvent::getMfd()
-{
- return mfd_id;
-}
-
-/*
----------------------------------------------------------------------
-*/
-
-MfdAudioPlayingEvent::MfdAudioPlayingEvent(
- int which_mfd,
- int which_playlist,
- int index_in_playlist,
- int which_collection_id,
- int which_metadata_id,
- int seconds_elapsed,
- int numb_channels,
- int what_bit_rate,
- int what_sample_frequency
- )
- :QCustomEvent(MFD_CLIENTLIB_EVENT_AUDIOPLAY)
-
-{
- mfd_id = which_mfd;
- playlist = which_playlist;
- playlist_index = index_in_playlist;
- collection_id = which_collection_id;
- metadata_id = which_metadata_id;
- seconds = seconds_elapsed;
- channels = numb_channels;
- bit_rate = what_bit_rate;
- sample_frequency = what_sample_frequency;
-}
-
-/*
----------------------------------------------------------------------
-*/
-
-MfdMetadataChangedEvent::MfdMetadataChangedEvent(
- int which_mfd,
- MfdContentCollection *new_collection
- )
- :QCustomEvent(MFD_CLIENTLIB_EVENT_METADATA)
-
-{
- mfd_id = which_mfd;
- new_mfd_collection = new_collection;
-}
-
-int MfdMetadataChangedEvent::getMfd()
-{
- return mfd_id;
-}
-
-MfdContentCollection* MfdMetadataChangedEvent::getNewCollection()
-{
- return new_mfd_collection;
-}
-
-/*
----------------------------------------------------------------------
-*/
-
-MfdAudioPluginExistsEvent::MfdAudioPluginExistsEvent(
- int which_mfd
- )
- :QCustomEvent(MFD_CLIENTLIB_EVENT_AUDIOPLUGIN_EXISTS)
-
-{
- mfd_id = which_mfd;
-}
-
-int MfdAudioPluginExistsEvent::getMfd()
-{
- return mfd_id;
-}
-
-/*
----------------------------------------------------------------------
-*/
-
-MfdPlaylistCheckedEvent::MfdPlaylistCheckedEvent()
- :QCustomEvent(MFD_CLIENTLIB_EVENT_PLAYLIST_CHECKED)
-
-{
-}
-
View
197 mfd/clientlib/events.h
@@ -1,197 +0,0 @@
-#ifndef EVENTS_H_
-#define EVENTS_H_
-/*
- events.h
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- events that get passed to mfdinterface
-
-*/
-
-#include <qevent.h>
-
-#include "mfdcontent.h"
-
-#define MFD_CLIENTLIB_EVENT_DISCOVERY 65432
-#define MFD_CLIENTLIB_EVENT_AUDIOPAUSE 65431
-#define MFD_CLIENTLIB_EVENT_AUDIOSTOP 65430
-#define MFD_CLIENTLIB_EVENT_AUDIOPLAY 65429
-#define MFD_CLIENTLIB_EVENT_METADATA 65428
-#define MFD_CLIENTLIB_EVENT_AUDIOPLUGIN_EXISTS 65427
-#define MFD_CLIENTLIB_EVENT_PLAYLIST_CHECKED 65426
-
-
-class MfdDiscoveryEvent: public QCustomEvent
-{
- //
- // Sent by discoverythread when it finds a new mfd
- //
-
- public:
-
- MfdDiscoveryEvent(
- bool is_it_lost_or_found,
- const QString &a_name,
- const QString &a_hostname,
- const QString &an_ip_address,
- int a_port
- );
-
- bool getLostOrFound();
- QString getName();
- QString getHost();
- QString getAddress();
- int getPort();
-
- private:
-
- bool lost_or_found;
- QString name;
- QString hostname;
- QString ip_address;
- int port;
-
-};
-
-class MfdAudioPausedEvent: public QCustomEvent
-{
- //
- // Sent by an audio service client when it discovers that audio it gets
- // "pause on" or "pause off"
- //
-
- public:
-
- MfdAudioPausedEvent(
- int which_mfd,
- bool on_or_off
- );
-
- int getMfd();
- bool getPaused();
-
-
- private:
-
- int mfd_id;
- bool paused_or_not;
-};
-
-class MfdAudioStoppedEvent: public QCustomEvent
-{
- //
- // Sent by an audio service client when audio is stopped
- //
-
- public:
-
- MfdAudioStoppedEvent(int which_mfd);
-
- int getMfd();
-
-
- private:
-
- int mfd_id;
-};
-
-class MfdAudioPlayingEvent: public QCustomEvent
-{
- //
- // Sent by an audio service client when audio is stopped
- //
-
- public:
-
- MfdAudioPlayingEvent(
- int which_mfd,
- int which_playlist,
- int index_in_playlist,
- int which_collection_id,
- int which_metadata_id,
- int seconds_elapsed,
- int numb_channels,
- int what_bit_rate,
- int what_sample_frequency
- );
-
- int getMfd(){return mfd_id;}
- int getPlaylist(){return playlist;}
- int getPlaylistIndex(){return playlist_index;}
- int getCollectionId(){return collection_id;}
- int getMetadataId(){return metadata_id;}
- int getSeconds(){return seconds;}
- int getChannels(){return channels;}
- int getBitrate(){return bit_rate;}
- int getSampleFrequency(){return sample_frequency;}
-
-
-
- private:
-
- int mfd_id;
- int playlist;
- int playlist_index;
- int collection_id;
- int metadata_id;
- int seconds;
- int channels;
- int bit_rate;
- int sample_frequency;
-};
-
-class MfdMetadataChangedEvent: public QCustomEvent
-{
- //
- // Sent by a metadata client when a new metadata tree is available
- //
-
- public:
-
- MfdMetadataChangedEvent(int which_mfd, MfdContentCollection *new_collection);
-
- int getMfd();
- MfdContentCollection* getNewCollection();
-
-
- private:
-
- int mfd_id;
- MfdContentCollection *new_mfd_collection;
-};
-
-class MfdAudioPluginExistsEvent: public QCustomEvent
-{
- //
- // Sent by mfdinstance when it discovers an audio plugin in it's mfd
- //
-
- public:
-
- MfdAudioPluginExistsEvent(int which_mfd);
-
- int getMfd();
-
- private:
-
- int mfd_id;
-};
-
-class MfdPlaylistCheckedEvent: public QCustomEvent
-{
- //
- // Sent by the playlist checking thread when it is finished massaging a
- // content tree
- //
-
- public:
-
- MfdPlaylistCheckedEvent();
-
-};
-
-
-
-#endif
View
41 mfd/clientlib/mdcaprequest.cpp
@@ -1,41 +0,0 @@
-/*
- mdcaprequest.cpp
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- A little object for making mdcap requests
-
-*/
-
-#include "mdcaprequest.h"
-
-MdcapRequest::MdcapRequest(
- const QString& l_base_url,
- const QString& l_host_address
- )
- :HttpOutRequest(l_base_url, l_host_address)
-{
-
-
- //
- // Add mdcap headers
- //
-
- addHeader("Client-MDCAP-Version: 2.0");
- addHeader("User-Agent: MythTV/1.0 (Probably Linux)");
-
- //
- // Add the server address (which the HTTP 1.1 spec is fairly adamant
- // *must* be in there)
- //
-
- QString host_line = QString("Host: %1").arg(host_address);
- addHeader(host_line);
-
-
-}
-
-MdcapRequest::~MdcapRequest()
-{
-}
View
36 mfd/clientlib/mdcaprequest.h
@@ -1,36 +0,0 @@
-#ifndef MDCAPREQUEST_H_
-#define MDCAPREQUEST_H_
-/*
- mdcaprequest.h
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- A little object for making mdcap requests
-
-*/
-
-#include <vector>
-using namespace std;
-
-#include <qstring.h>
-#include <qsocketdevice.h>
-#include <qdict.h>
-
-#include "../mfdlib/httpoutrequest.h"
-
-class MdcapRequest : public HttpOutRequest
-{
-
- public:
-
- MdcapRequest(
- const QString& l_base_url,
- const QString& l_host_address
- );
-
- ~MdcapRequest();
-
-};
-
-#endif
View
28 mfd/clientlib/mdcapresponse.cpp
@@ -1,28 +0,0 @@
-/*
- mdcapresponse.cpp
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- A little object for parsing incoming mdcap responses
-
-*/
-
-#include "mdcapresponse.h"
-
-MdcapResponse::MdcapResponse(
- char *raw_incoming,
- int length
- )
- :HttpInResponse(raw_incoming, length)
-{
-}
-
-void MdcapResponse::warning(const QString &warn_text)
-{
- cout << "WARNING mdcapresponse.o: " << warn_text << endl;
-}
-
-MdcapResponse::~MdcapResponse()
-{
-}
View
30 mfd/clientlib/mdcapresponse.h
@@ -1,30 +0,0 @@
-#ifndef MDCAPRESPONSE_H_
-#define MDCAPRESPONSE_H_
-/*
- mdcapresponse.h
-
- (c) 2003 Thor Sigvaldason and Isaac Richards
- Part of the mythTV project
-
- A little object for handling mdcap responses
-
-*/
-
-#include "../mfdlib/httpinresponse.h"
-
-class MdcapResponse : public HttpInResponse
-{
-
- public:
-
- MdcapResponse(
- char *raw_incoming,
- int length
- );
-
- ~MdcapResponse();
-
- void warning(const QString &warn_text);
-};
-
-#endif
View
379 mfd/clientlib/mdnsd/1035.c
@@ -1,379 +0,0 @@
-#include "1035.h"
-#include <string.h>
-#include <stdio.h>
-
-unsigned short int net2short(unsigned char **bufp)
-{
- short int i;
- i = **bufp;
- i <<= 8;
- i |= *(*bufp + 1);
- *bufp += 2;
- return i;
-}
-
-unsigned long int net2long(unsigned char **bufp)
-{
- long int l;
- l = **bufp;
- l <<= 8;
- l |= *(*bufp + 1);
- l <<= 8;
- l |= *(*bufp + 2);
- l <<= 8;
- l |= *(*bufp + 3);
- *bufp += 4;
- return l;
-}
-
-void short2net(unsigned short int i, unsigned char **bufp)
-{
- *(*bufp + 1) = (unsigned char)i;
- i >>= 8;
- **bufp = (unsigned char)i;
- *bufp += 2;
-}
-
-void long2net(unsigned long int l, unsigned char **bufp)
-{
- *(*bufp + 3) = (unsigned char)l;
- l >>= 8;
- *(*bufp + 2) = (unsigned char)l;
- l >>= 8;
- *(*bufp + 1) = (unsigned char)l;
- l >>= 8;
- **bufp = (unsigned char)l;
- *bufp += 4;
-}
-
-unsigned short int _ldecomp(unsigned char *ptr)
-{
- unsigned short int i;
- i = 0xc0 ^ ptr[0];
- i <<= 8;
- i |= ptr[1];
- if(i >= 4096) i = 4095;
- return i;
-}
-
-void _label(struct message *m, unsigned char **bufp, unsigned char **namep)
-{
- unsigned char *label, *name;
- int x;
-
- // set namep to the end of the block
- *namep = name = m->_packet + m->_len;
-
- // loop storing label in the block
- for(label = *bufp; *label != 0; name += *label + 1, label += *label + 1)
- {
- // skip past any compression pointers, kick out if end encountered (bad data prolly)
- while(*label & 0xc0)
- if(*(label = m->_buf + _ldecomp(label)) == 0) break;
-
- // make sure we're not over the limits
- if((name + *label) - *namep > 255 || m->_len + ((name + *label) - *namep) > 4096) return;
-
- // copy chars for this label
- memcpy(name,label+1,*label);
- name[*label] = '.';
- }
-
- // advance buffer
- for(label = *bufp; *label != 0 && !(*label & 0xc0 && label++); label += *label + 1);
- *bufp = label + 1;
-
- // terminate name and check for cache or cache it
- *name = '\0';
- for(x = 0; x <= 19 && m->_labels[x]; x++)
- {
- if(strcmp(*namep,m->_labels[x])) continue;
- *namep = m->_labels[x];
- return;
- }
- // no cache, so cache it if room
- if(x <= 19 && m->_labels[x] == 0)
- m->_labels[x] = *namep;
- m->_len += (name - *namep) + 1;
-}
-
-// internal label matching
-int _lmatch(struct message *m, unsigned char *l1, unsigned char *l2)
-{
- int len;
-
- // always ensure we get called w/o a pointer
- if(*l1 & 0xc0) return _lmatch(m, m->_buf + _ldecomp(l1),l2);
- if(*l2 & 0xc0) return _lmatch(m, l1, m->_buf + _ldecomp(l2));
-
- // same already?
- if(l1 == l2) return 1;
-
- // compare all label characters
- if(*l1 != *l2) return 0;
- for(len = 1; len <= *l1; len++)
- if(l1[len] != l2[len]) return 0;
-
- // get new labels
- l1 += *l1 + 1;
- l2 += *l2 + 1;
-
- // at the end, all matched
- if(*l1 == 0 && *l2 == 0) return 1;
-
- // try next labels
- return _lmatch(m,l1,l2);
-}
-
-// nasty, convert host into label using compression
-int _host(struct message *m, unsigned char **bufp, unsigned char *name)
-{
- unsigned char label[256], *l;
- int len = 0, x = 1, y = 0, last = 0;
-
- if(name == 0) return 0;
-
- // make our label
- while(name[y])
- {
- if(name[y] == '.')
- {
- if(!name[y+1]) break;
- label[last] = x - (last + 1);
- last = x;
- }else{
- label[x] = name[y];
- }
- if(x++ == 255) return 0;
- y++;
- }
- label[last] = x - (last + 1);
- if(x == 1) x--; // special case, bad names, but handle correctly
- len = x + 1;
- label[x] = 0; // always terminate w/ a 0
-
- // double-loop checking each label against all m->_labels for match
- for(x = 0; label[x]; x += label[x] + 1)
- {
- for(y = 0; m->_labels[y]; y++)
- if(_lmatch(m,label+x,m->_labels[y]))
- {
- // matching label, set up pointer
- l = label + x;
- short2net(m->_labels[y] - m->_packet, &l);
- label[x] |= 0xc0;
- len = x + 2;
- break;
- }
- if(label[x] & 0xc0) break;
- }
-
- // copy into buffer, point there now
- memcpy(*bufp,label,len);
- l = *bufp;
- *bufp += len;
-
- // for each new label, store it's location for future compression
- for(x = 0; l[x]; x += l[x] + 1)
- {
- if(l[x] & 0xc0) break;
- if(m->_label +