Skip to content

Commit 43f64de

Browse files
committed
First git commit.
0 parents  commit 43f64de

File tree

265 files changed

+97978
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+97978
-0
lines changed

README

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
QuickDC a portable p2p application for ADC/NMDC networks.
2+
3+
* Features built-in ADC hub
4+
* Multisource downloads
5+

core/api/cli.cpp

Whitespace-only changes.

core/api/cli.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace QuickDC {
2+
namespace CLI {
3+
4+
struct CommandTemplate {
5+
const char* cmd;
6+
size_t length;
7+
size_t params;
8+
const char* parse_args;
9+
const char* desc_args;
10+
const char* description;
11+
};
12+
13+
class ParsedCommand {
14+
public:
15+
ParsedCommand();
16+
virtual ~ParsedCommand();
17+
18+
protected:
19+
std::vector<char*> arguments;
20+
};
21+
22+
23+
24+
25+
}
26+
}

core/api/core.cpp

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright (C) 2001-2008 Jan Vidar Krey, [email protected]
3+
* See the file "COPYING" for licensing details.
4+
*/
5+
6+
#include "quickdc.h"
7+
8+
#include <samurai/io/net/bandwidth.h>
9+
#include <samurai/io/net/tlsfactory.h>
10+
#include <samurai/io/net/socketmonitor.h>
11+
#include <samurai/io/file.h>
12+
#include <samurai/timer.h>
13+
#include <samurai/timestamp.h>
14+
15+
#include <stdio.h>
16+
#include <string.h>
17+
#include <sys/stat.h>
18+
19+
#include "api/core.h"
20+
#include "api/server.h"
21+
#include "config/preferences.h"
22+
#include "network/connectionmanager.h"
23+
#include "network/downloadqueue.h"
24+
#include "network/hubmanager.h"
25+
#include "network/securitymanager.h"
26+
#include "network/transfermanager.h"
27+
#include "network/adc/server/adchub.h"
28+
29+
#include "share/sharemanager.h"
30+
#include "hash/hashmanager.h"
31+
32+
extern "C" QuickDC::Core* quickdc_core;
33+
34+
QuickDC::Core::Core()
35+
{
36+
QDBG_INIT;
37+
38+
startup = time(0);
39+
40+
references = 0;
41+
42+
Samurai::IO::File::mkdir("~/.quickdc", 0700);
43+
Samurai::IO::File::mkdir("~/.quickdc/hub", 0700);
44+
Samurai::IO::File::mkdir("~/.quickdc/hub/bbs", 0700);
45+
Samurai::IO::File::mkdir("~/.quickdc/lists", 0700);
46+
Samurai::IO::File::mkdir("~/.quickdc/ssl", 0700);
47+
48+
config = new Preferences("~/.quickdc/quickdc.conf");
49+
quickdc_core = this;
50+
51+
monitor = Samurai::IO::Net::SocketMonitor::getInstance();
52+
bandwidthManager = new Samurai::IO::Net::BandwidthManager();
53+
messageHandler = Samurai::MessageHandler::getInstance();
54+
securityManager = new QuickDC::SecurityManager();
55+
56+
Samurai::IO::Net::TlsFactory::setKeys("~/.quickdc/ssl/quickdc.key", "~/.quickdc/ssl/quickdc.crt");
57+
58+
hash = new QuickDC::Hash::Manager();
59+
shares = new QuickDC::Share::Manager(config, hash);
60+
server = new DCServer();
61+
connections = new ConnectionManager();
62+
hubs = new HubManager();
63+
transfers = new TransferManager();
64+
timers = new Samurai::TimerManager();
65+
localHub = new ADC::Hub();
66+
queue = new QuickDC::QueueManager();
67+
68+
shares->initialize();
69+
}
70+
71+
72+
QuickDC::Core::~Core() {
73+
quickdc_core = 0;
74+
delete timers; timers = 0;
75+
delete transfers; transfers = 0;
76+
delete connections; connections = 0;
77+
delete server; server = 0;
78+
delete hubs; hubs = 0;
79+
delete securityManager; securityManager = 0;
80+
delete shares; shares = 0;
81+
delete config; config = 0;
82+
delete hash; hash = 0;
83+
delete localHub; localHub = 0;
84+
delete bandwidthManager;
85+
delete messageHandler; messageHandler = 0;
86+
QDBG_FINI;
87+
}
88+
89+
90+
void QuickDC::Core::run() {
91+
// Poll sockets
92+
// FIXME: Wait for sigio, it's no point actually waiting!
93+
monitor->wait(1000);
94+
95+
// Make sure hashing is continued
96+
hash->process();
97+
98+
// Process timers.
99+
// FIXME: it should be sorted so we don't have to iterate ALL timers to
100+
// before exit.
101+
timers->process();
102+
103+
messageHandler->process();
104+
}
105+
106+
107+
QuickDC::Core* QuickDC::Core::getInstance()
108+
{
109+
return quickdc_core;
110+
}
111+
112+
113+
const char* QuickDC::Core::getVersion() const
114+
{
115+
return PRODUCT " " VERSION " " SYSTEM "/" CPU
116+
#ifdef BUILD
117+
" (build " BUILD ")"
118+
#endif
119+
;
120+
}
121+
122+

core/api/core.h

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright (C) 2001-2008 Jan Vidar Krey, [email protected]
3+
* See the file "COPYING" for licensing details.
4+
*/
5+
6+
#ifndef HAVE_QUICKDC_CORE_API_H
7+
#define HAVE_QUICKDC_CORE_API_H
8+
9+
#include <samurai/timestamp.h>
10+
11+
namespace Samurai {
12+
namespace IO {
13+
namespace Net {
14+
class BandwidthManager;
15+
class SocketMonitor;
16+
class Socket;
17+
}
18+
}
19+
20+
class TimerManager;
21+
class MessageHandler;
22+
}
23+
24+
25+
namespace ADC {
26+
class Hub;
27+
}
28+
29+
namespace QuickDC {
30+
namespace Hash { class Manager; }
31+
namespace Share { class Manager; }
32+
33+
class ConnectionManager;
34+
class DCCommandProxy;
35+
class DCHubSession;
36+
class DCServer;
37+
class HubManager;
38+
class Preferences;
39+
class Server;
40+
class ShareManager;
41+
class TransferManager;
42+
class QueueManager;
43+
class SecurityManager;
44+
45+
class Core {
46+
public:
47+
/**
48+
* Run the core for a while.
49+
* This needs to be run often in a loop, in order to
50+
* keep the networking going and messages dispatched.
51+
*
52+
* QuickDC core is asynchronous so calling this will
53+
* not block your application for a long time. Usually only
54+
* for milliseconds.
55+
*
56+
* In order to get good networking throughput, you should
57+
* call this method at least 20 times per second.
58+
*
59+
* This call will never block for a considerable long time.
60+
*/
61+
void run();
62+
63+
/**
64+
* Returns an instance of the running Core,
65+
* or it will create one if none is running.
66+
*/
67+
static Core* getInstance();
68+
69+
#if 0
70+
/**
71+
* Add a server listener. This will be notified
72+
* whenever the server receivs a connection.
73+
*/
74+
void AddServerListener(const DCServerListener*);
75+
#endif // 0
76+
77+
78+
public:
79+
/**
80+
* Returns the version string of the compiled QuickDC core.
81+
*/
82+
const char* getVersion() const;
83+
84+
public:
85+
Preferences* config;
86+
QuickDC::Share::Manager* shares;
87+
DCServer* server;
88+
ConnectionManager* connections;
89+
HubManager* hubs;
90+
QuickDC::Hash::Manager* hash;
91+
TransferManager* transfers;
92+
Samurai::TimerManager* timers;
93+
ADC::Hub* localHub;
94+
QuickDC::QueueManager* queue;
95+
Samurai::TimeStamp startup;
96+
Samurai::MessageHandler* messageHandler;
97+
Samurai::IO::Net::SocketMonitor* monitor;
98+
QuickDC::SecurityManager* securityManager;
99+
Samurai::IO::Net::BandwidthManager* bandwidthManager;
100+
101+
protected:
102+
int references;
103+
104+
public:
105+
/**
106+
* Note: only one Core object can exist
107+
* Constructing multiple will throw an error.
108+
*/
109+
Core();
110+
virtual ~Core();
111+
};
112+
113+
}
114+
115+
extern "C" QuickDC::Core* quickdc_core;
116+
117+
#endif // HAVE_QUICKDC_CORE_API_H

0 commit comments

Comments
 (0)