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

arts

  • arts
  • kde
kiotestslow.cc
1 #include <stdio.h>
2 #include <kmedia2.h>
3 #include <kcmdlineargs.h>
4 #include <connect.h>
5 #include <klocale.h>
6 #include <kapplication.h>
7 #include <kaboutdata.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 KCmdLineOptions options[] =
82 {
83  { "+[URL]", I18N_NOOP("URL to open"), 0 },
84  KCmdLineLastOption
85 };
86 
87 #undef USE_FILEINPUTSTREAM
88 
89 int main(int argc, char **argv)
90 {
91  KAboutData aboutData( "kiotestslow", I18N_NOOP("KIOTest"), I18N_NOOP("0.1"), "", KAboutData::License_GPL, "");
92 
93  KCmdLineArgs::init(argc,argv,&aboutData);
94  KCmdLineArgs::addCmdLineOptions(options);
95  KApplication app;
96  QIOManager qiomanager;
97  Dispatcher dispatcher(&qiomanager);
98 #ifndef USE_FILEINPUTSTREAM
99  KIOInputStream stream;
100 #else
101  FileInputStream stream;
102 #endif
103  KIOTestSlow writer;
104 
105  KCmdLineArgs *args = KCmdLineArgs::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 }
KApplication
KCmdLineArgs
KCmdLineArgs::parsedArgs
static KCmdLineArgs * parsedArgs(const char *id=0)
std
klocale.h
KCmdLineArgs::count
int count() const
KCmdLineOptions
I18N_NOOP
#define I18N_NOOP(x)
Arts
Definition: kartsdispatcher.h:29
KAboutData
KCmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noKApp=false)
KCmdLineArgs::addCmdLineOptions
static void addCmdLineOptions(const KCmdLineOptions *options, const char *name=0, const char *id=0, const char *afterId=0)
KCmdLineArgs::arg
const char * arg(int n) const
KCmdLineArgs::clear
void clear()

arts

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

arts

Skip menu "arts"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for arts by doxygen 1.8.8
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |