• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • arts
 

arts

  • arts
  • kde
kiotestslow.cpp
1 #include <stdio.h>
2 #include <kmedia2.h>
3 #include <tdecmdlineargs.h>
4 #include <connect.h>
5 #include <tdelocale.h>
6 #include <tdeapplication.h>
7 #include <tdeaboutdata.h>
8 #include <stdsynthmodule.h>
9 #include "qiomanager.h"
10 #include "artskde.h"
11 
12 using namespace std;
13 using namespace Arts;
14 
15 namespace Arts {
16 /* simulate slow receiver */
17 class KIOTestSlow_impl : public KIOTestSlow_skel,
18  public TimeNotify,
19  public StdSynthModule
20 {
21  int pos;
22  list< DataPacket<mcopbyte>* > q;
23  InputStream _inputStream;
24 
25 public:
26  InputStream inputStream() { return _inputStream; }
27  void inputStream(InputStream i) { _inputStream = i; }
28 
29  KIOTestSlow_impl()
30  {
31  Dispatcher::the()->ioManager()->addTimer(10, this);
32  pos = 0;
33  }
34  void notifyTime()
35  {
36  if(!_inputStream.isNull() && _inputStream.eof())
37  {
38  printf("\n[*EOF*] remaining = %d packets\n");
39  _inputStream = InputStream::null();
40  return;
41  }
42 
43  int TODO = 100;
44  do {
45  if(q.empty())
46  return;
47 
48  DataPacket<mcopbyte> *p = q.front();
49  char ch = p->contents[pos++];
50  if(p->size == pos)
51  {
52  p->processed();
53  q.pop_front();
54  pos = 0;
55  }
56 
57  if(ch == '\n')
58  {
59  long size = 0;
60  list<DataPacket<mcopbyte>*>::iterator i;
61  for(i = q.begin(); i != q.end(); i++)
62  size += (*i)->size;
63  printf("\n[queued %8ld] ",size-pos);
64  }
65  else
66  putchar(ch);
67 
68  } while(TODO-- > 0);
69  }
70  void process_data(DataPacket<mcopbyte> *p)
71  {
72  if(p->size == 0)
73  p->processed();
74  else
75  q.push_back(p);
76  }
77 };
78 REGISTER_IMPLEMENTATION(KIOTestSlow_impl);
79 };
80 
81 static TDECmdLineOptions options[] =
82 {
83  { "+[URL]", I18N_NOOP("URL to open"), 0 },
84  TDECmdLineLastOption
85 };
86 
87 #undef USE_FILEINPUTSTREAM
88 
89 int main(int argc, char **argv)
90 {
91  TDEAboutData aboutData( "kiotestslow", I18N_NOOP("KIOTest"), I18N_NOOP("0.1"), "", TDEAboutData::License_GPL, "");
92 
93  TDECmdLineArgs::init(argc,argv,&aboutData);
94  TDECmdLineArgs::addCmdLineOptions(options);
95  TDEApplication app;
96  QIOManager qiomanager;
97  Dispatcher dispatcher(&qiomanager);
98 #ifndef USE_FILEINPUTSTREAM
99  TDEIOInputStream stream;
100 #else
101  FileInputStream stream;
102 #endif
103  KIOTestSlow writer;
104 
105  TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
106 
107  if(args->count())
108  {
109 #ifdef USE_FILEINPUTSTREAM
110  if(!stream.open(args->arg(0)))
111 #else
112  if(!stream.openURL(args->arg(0)))
113 #endif
114  {
115  printf("can't open url");
116  exit(1);
117  }
118  }
119  else
120  exit(1);
121 
122  args->clear();
123 
124  writer.inputStream(stream);
125  connect(stream, writer);
126 
127  writer.start();
128  stream.start();
129 
130  app.exec();
131 }
TDECmdLineArgs
TDECmdLineArgs::clear
void clear()
TDEAboutData
TDECmdLineArgs::addCmdLineOptions
static void addCmdLineOptions(const TDECmdLineOptions *options, const char *name=0, const char *id=0, const char *afterId=0)
std
TDEApplication
I18N_NOOP
#define I18N_NOOP(x)
tdelocale.h
TDECmdLineArgs::parsedArgs
static TDECmdLineArgs * parsedArgs(const char *id=0)
Arts
Definition: kartsdispatcher.h:29
TDECmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noKApp=false)
TDECmdLineArgs::count
int count() const
TDECmdLineArgs::arg
const char * arg(int n) const
TDECmdLineOptions

arts

Skip menu "arts"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

arts

Skip menu "arts"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for arts by doxygen 1.8.8
This website is maintained by Timothy Pearson.