git-svn-id: svn://db.shs.com.ru/pip@223 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -231,3 +231,4 @@ add_subdirectory("utils/remote_console")
|
||||
add_subdirectory("utils/code_model_generator")
|
||||
add_subdirectory("utils/system_daemon")
|
||||
add_subdirectory("utils/udp_file_transfer")
|
||||
add_subdirectory("utils/picrypt")
|
||||
|
||||
@@ -131,7 +131,7 @@ PRIVATE_DEFINITION_START(PIKbdListener)
|
||||
PRIVATE_DEFINITION_END(PIKbdListener)
|
||||
|
||||
|
||||
PIKbdListener::PIKbdListener(KBFunc slot, void * _data): PIThread() {
|
||||
PIKbdListener::PIKbdListener(KBFunc slot, void * _data, bool startNow): PIThread() {
|
||||
setName("keyboard_listener");
|
||||
_object = this;
|
||||
#ifdef WINDOWS
|
||||
@@ -144,7 +144,7 @@ PIKbdListener::PIKbdListener(KBFunc slot, void * _data): PIThread() {
|
||||
ret_func = slot;
|
||||
data_ = _data;
|
||||
PIKbdListener::exiting = exit_enabled = false;
|
||||
start();
|
||||
if (startNow) start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
|
||||
|
||||
//! Constructs keyboard listener with external function "slot" and custom data "data"
|
||||
explicit PIKbdListener(KBFunc slot = 0, void * data = 0);
|
||||
explicit PIKbdListener(KBFunc slot = 0, void * data = 0, bool startNow = true);
|
||||
|
||||
~PIKbdListener();
|
||||
|
||||
|
||||
@@ -323,14 +323,21 @@ PIScreen::PIScreen(bool startNow, PIKbdListener::KBFunc slot): PIThread(), drawe
|
||||
ret_func = slot;
|
||||
tile_focus = tile_dialog = 0;
|
||||
root.screen = this;
|
||||
listener = new PIKbdListener(key_eventS, this);
|
||||
listener = new PIKbdListener(key_eventS, this, startNow);
|
||||
if (startNow) start();
|
||||
}
|
||||
|
||||
|
||||
PIScreen::~PIScreen() {
|
||||
piCoutObj << "~PIScreen";
|
||||
if (isRunning())
|
||||
stop();
|
||||
piCoutObj << "stop PIScreen .. ";
|
||||
PIThread::waitForFinish(10);
|
||||
piCoutObj << "stop PIScreen ok";
|
||||
piCoutObj << "stop listener .. ";
|
||||
listener->waitForFinish(10);
|
||||
piCoutObj << "stop listener ok";
|
||||
delete listener;
|
||||
}
|
||||
|
||||
@@ -462,6 +469,7 @@ void PIScreen::stop(bool clear) {
|
||||
|
||||
|
||||
void PIScreen::begin() {
|
||||
listener->start();
|
||||
nextFocus(&root);
|
||||
console.begin();
|
||||
}
|
||||
@@ -493,6 +501,7 @@ void PIScreen::run() {
|
||||
|
||||
|
||||
void PIScreen::end() {
|
||||
listener->stop();
|
||||
console.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class PIP_EXPORT PIScreen: public PIThread, public PIScreenTypes::PIScreenBase
|
||||
public:
|
||||
|
||||
//! Constructs %PIScreen with key handler "slot" and if "startNow" start it
|
||||
PIScreen(bool startNow = false, PIKbdListener::KBFunc slot = 0);
|
||||
PIScreen(bool startNow = true, PIKbdListener::KBFunc slot = 0);
|
||||
|
||||
~PIScreen();
|
||||
|
||||
|
||||
@@ -430,21 +430,19 @@ bool PIString::operator >(const PIString & str) const {
|
||||
PIString PIString::mid(const int start, const int len) const {
|
||||
//PIString str;
|
||||
int s = start, l = len;
|
||||
if (l == 0 || start >= length()) return PIString();
|
||||
if (l == 0 || s >= length()) return PIString();
|
||||
if (s < 0) {
|
||||
l += s;
|
||||
s = 0;
|
||||
}
|
||||
if (l < 0) {
|
||||
//for (uint i = s; i < size(); ++i)
|
||||
// str += at(i);
|
||||
return PIString(&(at(s)), size_s() - s);
|
||||
} else {
|
||||
if (l > length() - s)
|
||||
l = length() - s;
|
||||
//for (int i = s; i < s + l; ++i)
|
||||
// str += at(i);
|
||||
//std::cout << "mid " << s << " " << l << " " << size_s() << " " << start << " " << len << "\n";
|
||||
// std::cout << "mid " << s << " " << l << " " << size_s() << " " << start << " " << len << "\n";
|
||||
return PIString(&(at(s)), l);
|
||||
}
|
||||
return PIString();
|
||||
@@ -795,6 +793,25 @@ PIString PIString::takeRange(const PIChar & start, const PIChar & end, const PIC
|
||||
}
|
||||
|
||||
|
||||
PIString PIString::inBrackets(const PIChar &start, const PIChar &end) const {
|
||||
int slen = length();
|
||||
int st = -1, bcnt = 0;
|
||||
PIChar cc;
|
||||
for (int i = 0; i < slen; i++) {
|
||||
cc = at(i);
|
||||
if (cc == start) {
|
||||
if (bcnt == 0) st = i;
|
||||
bcnt++;
|
||||
}
|
||||
if (cc == end && st >= 0) {
|
||||
bcnt--;
|
||||
if (bcnt == 0) return mid(st+1, i-st-1);
|
||||
}
|
||||
}
|
||||
return PIString();
|
||||
}
|
||||
|
||||
|
||||
PIString PIString::toUpperCase() const {
|
||||
PIString str(*this);
|
||||
int l = str.size();
|
||||
|
||||
@@ -450,8 +450,11 @@ public:
|
||||
* \sa \a takeSymbol(), \a takeWord(), \a takeLine(), \a takeNumber() */
|
||||
PIString takeRange(const PIChar & start, const PIChar & end, const PIChar & shield = '\\');
|
||||
|
||||
//const char * data() {return convertToStd().c_str();}
|
||||
|
||||
|
||||
/*! \brief Return a string in brackets "start" and "end" symbols from the begin of this
|
||||
* string and return it.
|
||||
* \details Example: string = "a(b(c)d)e"; inBrackets('(', ')') = "b(c)d"; */
|
||||
PIString inBrackets(const PIChar & start, const PIChar & end) const;
|
||||
|
||||
/*! \brief Return real bytes count of this string
|
||||
* \details It`s equivalent length of char sequence
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#define PIP_VERSION_MAJOR 0
|
||||
#define PIP_VERSION_MINOR 5
|
||||
#define PIP_VERSION_REVISION 4
|
||||
#define PIP_VERSION_REVISION 5
|
||||
#define PIP_VERSION_SUFFIX ""
|
||||
|
||||
#endif // PIVERSION_H
|
||||
|
||||
@@ -124,24 +124,23 @@ private:
|
||||
void usage() {
|
||||
piCout << Bold << "PIP UDP file transfer";
|
||||
piCout << Cyan << "Version" << Bold << PIPVersion() << NewLine;
|
||||
piCout << Green << Bold << "Usage:" << Default << "\"pift [-hqf] -r <receive_ip> -s <send_ip> [-d <work_dir>] [-p port] [<path1>] [<path2>] [<path3>] [...]\"" << NewLine;
|
||||
piCout << Green << Bold << "Usage:" << Default << "\"pift [-hqf] -r <receive_ip> -s <send_ip> [-d <work_dir>] [-p <port>] [<path1>] [<path2>] [<path3>] [...]\"" << NewLine;
|
||||
piCout << Green << Bold << "Details:";
|
||||
piCout << "-f " << Green << "- full path in <receive_ip> and <send_ip>";
|
||||
piCout << "-h " << Green << "- display this message and exit";
|
||||
piCout << "-q " << Green << "- quiet, no debug output to console";
|
||||
piCout << "-r " << Green << "- set receive ip address, must be ip address of this computer";
|
||||
piCout << "-s " << Green << "- set send ip address, address of computer which communicate with you";
|
||||
piCout << "-p " << Green << "- UDP port for transfer, by default 50005";
|
||||
piCout << "-d <work_dir> " << Green << "- directory, where place received files";
|
||||
piCout << "<path> " << Green << "- add path to send, if no path, then \"pift\" working in receive mode";
|
||||
piCout << "-t " << Green << "- test mode";
|
||||
piCout << "-f --fullpath " << Green << "- full path in <receive_ip> and <send_ip>";
|
||||
piCout << "-h --help " << Green << "- display this message and exit";
|
||||
piCout << "-q --quet " << Green << "- quiet, no debug output to console";
|
||||
piCout << "-r --receive <receive_ip> " << Green << "- set receive ip address, must be ip address of this computer";
|
||||
piCout << "-s --send <send_ip> " << Green << "- set send ip address, address of computer which communicate with you";
|
||||
piCout << "-p --port <port> " << Green << "- UDP port for transfer, by default 50005";
|
||||
piCout << "-d --dir <work_dir> " << Green << "- directory, where place received files";
|
||||
piCout << "<path> " << Green << "- add path to send, if no path, then \"pift\" working in receive mode";
|
||||
piCout << "-t --test " << Green << "- test mode";
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char * argv[]) {
|
||||
PICLI cli(argc, argv);
|
||||
PIINTROSPECTION_START
|
||||
cli.setOptionalArgumentsCount(-1);
|
||||
cli.setOptionalArgumentsCount(-1);
|
||||
cli.addArgument("send", true);
|
||||
cli.addArgument("receive", true);
|
||||
cli.addArgument("dir", true);
|
||||
@@ -201,7 +200,7 @@ int main (int argc, char * argv[]) {
|
||||
}
|
||||
kbd.start();
|
||||
WAIT_FOR_EXIT
|
||||
PICout(0) << "\n";
|
||||
PICout(0) << "\n";
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user