back to polygonf
git-svn-id: svn://db.shs.com.ru/pip@105 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
project(pip)
|
project(pip)
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -pg")
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
PIDeque<T> * parent;
|
PIDeque<T> * parent;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
public:
|
public:
|
||||||
iterator(): parent(0) {}
|
iterator(): parent(0), pos(0) {}
|
||||||
T & operator *() {return (*parent)[pos];}
|
T & operator *() {return (*parent)[pos];}
|
||||||
const T & operator *() const {return (*parent)[pos];}
|
const T & operator *() const {return (*parent)[pos];}
|
||||||
void operator ++() {++pos;}
|
void operator ++() {++pos;}
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
const PIDeque<T> * parent;
|
const PIDeque<T> * parent;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
public:
|
public:
|
||||||
const_iterator(): parent(0) {}
|
const_iterator(): parent(0), pos(0) {}
|
||||||
//T & operator *() {return (*parent)[pos];}
|
//T & operator *() {return (*parent)[pos];}
|
||||||
const T & operator *() const {return (*parent)[pos];}
|
const T & operator *() const {return (*parent)[pos];}
|
||||||
void operator ++() {++pos;}
|
void operator ++() {++pos;}
|
||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
PIDeque<T> * parent;
|
PIDeque<T> * parent;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
public:
|
public:
|
||||||
reverse_iterator(): parent(0) {}
|
reverse_iterator(): parent(0), pos(0) {}
|
||||||
T & operator *() {return (*parent)[pos];}
|
T & operator *() {return (*parent)[pos];}
|
||||||
const T & operator *() const {return (*parent)[pos];}
|
const T & operator *() const {return (*parent)[pos];}
|
||||||
void operator ++() {--pos;}
|
void operator ++() {--pos;}
|
||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
const PIDeque<T> * parent;
|
const PIDeque<T> * parent;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
public:
|
public:
|
||||||
const_reverse_iterator(): parent(0) {}
|
const_reverse_iterator(): parent(0), pos(0) {}
|
||||||
//T & operator *() {return (*parent)[pos];}
|
//T & operator *() {return (*parent)[pos];}
|
||||||
const T & operator *() const {return (*parent)[pos];}
|
const T & operator *() const {return (*parent)[pos];}
|
||||||
void operator ++() {--pos;}
|
void operator ++() {--pos;}
|
||||||
@@ -333,7 +333,7 @@ private:
|
|||||||
for (size_t i = 0; i < s; ++i)
|
for (size_t i = 0; i < s; ++i)
|
||||||
elementNew(dst + i, src[i]);
|
elementNew(dst + i, src[i]);
|
||||||
}
|
}
|
||||||
inline T * newRaw(size_t s) {
|
static T * newRaw(size_t s) {
|
||||||
//std::cout << std::dec << " ![("<<this<<")newRaw " << s << " elements ... <" << std::endl;
|
//std::cout << std::dec << " ![("<<this<<")newRaw " << s << " elements ... <" << std::endl;
|
||||||
//uchar * ret = new uchar[s * sizeof(T)];
|
//uchar * ret = new uchar[s * sizeof(T)];
|
||||||
uchar * ret = (uchar*)(malloc(s * sizeof(T)));//new uchar[];
|
uchar * ret = (uchar*)(malloc(s * sizeof(T)));//new uchar[];
|
||||||
@@ -354,13 +354,13 @@ private:
|
|||||||
}
|
}
|
||||||
//cout << " > ok]~" << endl;
|
//cout << " > ok]~" << endl;
|
||||||
}
|
}
|
||||||
inline void deleteRaw(T *& d) {
|
static void deleteRaw(T *& d) {
|
||||||
//cout << " ~[("<<this<<")deleteRaw " << std::dec << pid_rsize << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
|
//cout << " ~[("<<this<<")deleteRaw " << std::dec << pid_rsize << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
|
||||||
if ((uchar*)d != 0) free((uchar*)d);
|
if ((uchar*)d != 0) free((uchar*)d);
|
||||||
d = 0;
|
d = 0;
|
||||||
//cout << " > ok]~" << endl;
|
//cout << " > ok]~" << endl;
|
||||||
}
|
}
|
||||||
void zeroRaw(T * d, size_t s) {
|
static void zeroRaw(T * d, size_t s) {
|
||||||
//cout << " ~[("<<this<<")zeroRaw " << std::dec << s << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
|
//cout << " ~[("<<this<<")zeroRaw " << std::dec << s << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
|
||||||
if ((uchar*)d != 0) memset(d, 0, s*sizeof(T));
|
if ((uchar*)d != 0) memset(d, 0, s*sizeof(T));
|
||||||
//cout << " > ok]~" << endl;
|
//cout << " > ok]~" << endl;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
const PIMap<Key, T> * parent;
|
const PIMap<Key, T> * parent;
|
||||||
ssize_t pos;
|
ssize_t pos;
|
||||||
public:
|
public:
|
||||||
iterator(): parent(0) {}
|
iterator(): parent(0), pos(0) {}
|
||||||
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
|
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
|
||||||
T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
|
T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
|
||||||
void operator ++() {++pos;}
|
void operator ++() {++pos;}
|
||||||
@@ -95,7 +95,7 @@ public:
|
|||||||
const PIMap<Key, T> * parent;
|
const PIMap<Key, T> * parent;
|
||||||
ssize_t pos;
|
ssize_t pos;
|
||||||
public:
|
public:
|
||||||
reverse_iterator(): parent(0) {}
|
reverse_iterator(): parent(0), pos(0) {}
|
||||||
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
|
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
|
||||||
T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
|
T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
|
||||||
void operator ++() {--pos;}
|
void operator ++() {--pos;}
|
||||||
@@ -113,7 +113,7 @@ public:
|
|||||||
const PIMap<Key, T> * parent;
|
const PIMap<Key, T> * parent;
|
||||||
ssize_t pos;
|
ssize_t pos;
|
||||||
public:
|
public:
|
||||||
const_iterator(): parent(0) {}
|
const_iterator(): parent(0), pos(0) {}
|
||||||
const PIMap<Key, T>::value_type operator *() const {return parent->_pair(pos);}
|
const PIMap<Key, T>::value_type operator *() const {return parent->_pair(pos);}
|
||||||
const PIMap<Key, T>::value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
|
const PIMap<Key, T>::value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
|
||||||
void operator ++() {++pos;}
|
void operator ++() {++pos;}
|
||||||
@@ -132,7 +132,7 @@ public:
|
|||||||
const PIMap<Key, T> * parent;
|
const PIMap<Key, T> * parent;
|
||||||
ssize_t pos;
|
ssize_t pos;
|
||||||
public:
|
public:
|
||||||
const_reverse_iterator(): parent(0) {}
|
const_reverse_iterator(): parent(0), pos(0) {}
|
||||||
const PIMap<Key, T>::value_type operator *() const {return parent->_pair(pos);}
|
const PIMap<Key, T>::value_type operator *() const {return parent->_pair(pos);}
|
||||||
const PIMap<Key, T>::value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
|
const PIMap<Key, T>::value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
|
||||||
void operator ++() {--pos;}
|
void operator ++() {--pos;}
|
||||||
@@ -422,7 +422,7 @@ template<typename Key, typename Type>
|
|||||||
inline std::ostream & operator <<(std::ostream & s, const PIMap<Key, Type> & v) {
|
inline std::ostream & operator <<(std::ostream & s, const PIMap<Key, Type> & v) {
|
||||||
s << "{";
|
s << "{";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (typename PIMap<Key, Type>::const_iterator i = v.begin(); i != v.end(); i++) {
|
for (typename PIMap<Key, Type>::const_iterator i = v.begin(); i != v.end(); ++i) {
|
||||||
if (!first)
|
if (!first)
|
||||||
s << ", ";
|
s << ", ";
|
||||||
first = false;
|
first = false;
|
||||||
@@ -438,7 +438,7 @@ inline PICout operator <<(PICout s, const PIMap<Key, Type> & v) {
|
|||||||
s.setControl(0, true);
|
s.setControl(0, true);
|
||||||
s << "{";
|
s << "{";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (typename PIMap<Key, Type>::const_iterator i = v.begin(); i != v.end(); i++) {
|
for (typename PIMap<Key, Type>::const_iterator i = v.begin(); i != v.end(); ++i) {
|
||||||
if (!first)
|
if (!first)
|
||||||
s << ", ";
|
s << ", ";
|
||||||
first = false;
|
first = false;
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
PIVector<T> * parent;
|
PIVector<T> * parent;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
public:
|
public:
|
||||||
iterator(): parent(0) {}
|
iterator(): parent(0), pos(0) {}
|
||||||
T & operator *() {return (*parent)[pos];}
|
T & operator *() {return (*parent)[pos];}
|
||||||
const T & operator *() const {return (*parent)[pos];}
|
const T & operator *() const {return (*parent)[pos];}
|
||||||
void operator ++() {++pos;}
|
void operator ++() {++pos;}
|
||||||
@@ -121,7 +121,7 @@ public:
|
|||||||
const PIVector<T> * parent;
|
const PIVector<T> * parent;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
public:
|
public:
|
||||||
const_iterator(): parent(0) {}
|
const_iterator(): parent(0), pos(0) {}
|
||||||
//T & operator *() {return (*parent)[pos];}
|
//T & operator *() {return (*parent)[pos];}
|
||||||
const T & operator *() const {return (*parent)[pos];}
|
const T & operator *() const {return (*parent)[pos];}
|
||||||
void operator ++() {++pos;}
|
void operator ++() {++pos;}
|
||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
PIVector<T> * parent;
|
PIVector<T> * parent;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
public:
|
public:
|
||||||
reverse_iterator(): parent(0) {}
|
reverse_iterator(): parent(0), pos(0) {}
|
||||||
T & operator *() {return (*parent)[pos];}
|
T & operator *() {return (*parent)[pos];}
|
||||||
const T & operator *() const {return (*parent)[pos];}
|
const T & operator *() const {return (*parent)[pos];}
|
||||||
void operator ++() {--pos;}
|
void operator ++() {--pos;}
|
||||||
@@ -157,7 +157,7 @@ public:
|
|||||||
const PIVector<T> * parent;
|
const PIVector<T> * parent;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
public:
|
public:
|
||||||
const_reverse_iterator(): parent(0) {}
|
const_reverse_iterator(): parent(0), pos(0) {}
|
||||||
//T & operator *() {return (*parent)[pos];}
|
//T & operator *() {return (*parent)[pos];}
|
||||||
const T & operator *() const {return (*parent)[pos];}
|
const T & operator *() const {return (*parent)[pos];}
|
||||||
void operator ++() {--pos;}
|
void operator ++() {--pos;}
|
||||||
@@ -331,13 +331,13 @@ private:
|
|||||||
}
|
}
|
||||||
//cout << " > ok]~" << endl;
|
//cout << " > ok]~" << endl;
|
||||||
}
|
}
|
||||||
void deleteRaw(T *& d) {
|
inline void deleteRaw(T *& d) {
|
||||||
//cout << " ~[("<<this<<")deleteRaw " << std::dec << piv_rsize << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
|
//cout << " ~[("<<this<<")deleteRaw " << std::dec << piv_rsize << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
|
||||||
if ((uchar*)d != 0) free((uchar*)d);
|
if ((uchar*)d != 0) free((uchar*)d);
|
||||||
d = 0;
|
d = 0;
|
||||||
//cout << " > ok]~" << endl;
|
//cout << " > ok]~" << endl;
|
||||||
}
|
}
|
||||||
void zeroRaw(T * d, size_t s) {
|
inline void zeroRaw(T * d, size_t s) {
|
||||||
//cout << " ~[("<<this<<")zeroRaw " << std::dec << s << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
|
//cout << " ~[("<<this<<")zeroRaw " << std::dec << s << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
|
||||||
if ((uchar*)d != 0) memset(d, 0, s*sizeof(T));
|
if ((uchar*)d != 0) memset(d, 0, s*sizeof(T));
|
||||||
//cout << " > ok]~" << endl;
|
//cout << " > ok]~" << endl;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
void operator =(const ullong & val) {resize(sizeof(val) * 8); memcpy(data(), &val, sizeof(val));}
|
void operator =(const ullong & val) {resize(sizeof(val) * 8); memcpy(data(), &val, sizeof(val));}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint bytesInBits(const uint & bits) const {return (bits + 7) / 8;}
|
static uint bytesInBits(const uint & bits) {return (bits + 7) / 8;}
|
||||||
|
|
||||||
PIVector<uchar> data_;
|
PIVector<uchar> data_;
|
||||||
uint size_;
|
uint size_;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ PICout PICout::operator <<(const PICoutAction v) {
|
|||||||
memset(line, ' ', dx);
|
memset(line, ' ', dx);
|
||||||
line[dx] = 0;
|
line[dx] = 0;
|
||||||
printf("%s", line);
|
printf("%s", line);
|
||||||
delete line;
|
delete[] line;
|
||||||
}
|
}
|
||||||
SetConsoleCursorPosition(__Private__::hOut, coord);
|
SetConsoleCursorPosition(__Private__::hOut, coord);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public:
|
|||||||
PICout operator <<(const PICoutManipulators::PICoutSpecialChar v);
|
PICout operator <<(const PICoutManipulators::PICoutSpecialChar v);
|
||||||
|
|
||||||
//! Output operator for \a PIFlags<PICoutFormat> values
|
//! Output operator for \a PIFlags<PICoutFormat> values
|
||||||
PICout operator <<(const PIFlags<PICoutManipulators::PICoutFormat> v) {
|
PICout operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v) {
|
||||||
if (v[PICoutManipulators::Bin]) cnb_ = 2;
|
if (v[PICoutManipulators::Bin]) cnb_ = 2;
|
||||||
if (v[PICoutManipulators::Oct]) cnb_ = 8;
|
if (v[PICoutManipulators::Oct]) cnb_ = 8;
|
||||||
if (v[PICoutManipulators::Dec]) cnb_ = 10;
|
if (v[PICoutManipulators::Dec]) cnb_ = 10;
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ void PIString::appendFromChars(const char * c, int s, const char * cp) {
|
|||||||
//printf("appendFromChars %d -> %d\n", s, rs);
|
//printf("appendFromChars %d -> %d\n", s, rs);
|
||||||
for (int i = 0; i < rs; ++i)
|
for (int i = 0; i < rs; ++i)
|
||||||
push_back(PIChar(ucs[i]));
|
push_back(PIChar(ucs[i]));
|
||||||
delete ucs;
|
delete[] ucs;
|
||||||
ucnv_close(cc);
|
ucnv_close(cc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -510,7 +510,7 @@ int PIString::find(const char str, const int start) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::find(const PIString str, const int start) const {
|
int PIString::find(const PIString & str, const int start) const {
|
||||||
int l = str.length();
|
int l = str.length();
|
||||||
for (int i = start; i < length() - l + 1; ++i)
|
for (int i = start; i < length() - l + 1; ++i)
|
||||||
if (mid(i, l) == str)
|
if (mid(i, l) == str)
|
||||||
@@ -527,7 +527,7 @@ int PIString::findLast(const char str, const int start) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::findLast(const PIString str, const int start) const {
|
int PIString::findLast(const PIString & str, const int start) const {
|
||||||
int l = str.length();
|
int l = str.length();
|
||||||
for (int i = length() - l; i >= start; --i)
|
for (int i = length() - l; i >= start; --i)
|
||||||
if (mid(i, l) == str)
|
if (mid(i, l) == str)
|
||||||
|
|||||||
@@ -529,7 +529,7 @@ public:
|
|||||||
|
|
||||||
//! \brief Search substring "str" from symbol at index "start" and return first occur position
|
//! \brief Search substring "str" from symbol at index "start" and return first occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::find
|
//! \details Example: \snippet pistring.cpp PIString::find
|
||||||
int find(const PIString str, const int start = 0) const;
|
int find(const PIString & str, const int start = 0) const;
|
||||||
|
|
||||||
//! \brief Search substring "str" from symbol at index "start" and return first occur position
|
//! \brief Search substring "str" from symbol at index "start" and return first occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::find
|
//! \details Example: \snippet pistring.cpp PIString::find
|
||||||
@@ -541,7 +541,7 @@ public:
|
|||||||
|
|
||||||
//! \brief Search substring "str" from symbol at index "start" and return last occur position
|
//! \brief Search substring "str" from symbol at index "start" and return last occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findLast
|
//! \details Example: \snippet pistring.cpp PIString::findLast
|
||||||
int findLast(const PIString str, const int start = 0) const;
|
int findLast(const PIString & str, const int start = 0) const;
|
||||||
|
|
||||||
//! \brief Search substring "str" from symbol at index "start" and return last occur position
|
//! \brief Search substring "str" from symbol at index "start" and return last occur position
|
||||||
//! \details Example: \snippet pistring.cpp PIString::findLast
|
//! \details Example: \snippet pistring.cpp PIString::findLast
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ PISystemTime::PISystemTime(const FILETIME & t) {
|
|||||||
|
|
||||||
PISystemTime PISystemTime::abs() const {
|
PISystemTime PISystemTime::abs() const {
|
||||||
if (seconds < 0)
|
if (seconds < 0)
|
||||||
return PISystemTime(piAbsl(seconds) - 1, 1e+9 - piAbsl(nanoseconds));
|
return PISystemTime(piAbsl(seconds) - 1, 1000000000l - piAbsl(nanoseconds));
|
||||||
else
|
else
|
||||||
return PISystemTime(piAbsl(seconds), piAbsl(nanoseconds));
|
return PISystemTime(piAbsl(seconds), piAbsl(nanoseconds));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,10 +298,10 @@ public:
|
|||||||
//! \brief Returns PISystemTime elapsed from last \a reset() execution or from timer measurer creation.
|
//! \brief Returns PISystemTime elapsed from last \a reset() execution or from timer measurer creation.
|
||||||
PISystemTime elapsed();
|
PISystemTime elapsed();
|
||||||
|
|
||||||
double reset_time_n() {return t_st.toNanoseconds();}
|
double reset_time_n() const {return t_st.toNanoseconds();}
|
||||||
double reset_time_u() {return t_st.toMicroseconds();}
|
double reset_time_u() const {return t_st.toMicroseconds();}
|
||||||
double reset_time_m() {return t_st.toMilliseconds();}
|
double reset_time_m() const {return t_st.toMilliseconds();}
|
||||||
double reset_time_s() {return t_st.toSeconds();}
|
double reset_time_s() const {return t_st.toSeconds();}
|
||||||
|
|
||||||
//! \brief Returns time mark of last \a reset() execution or timer measurer creation.
|
//! \brief Returns time mark of last \a reset() execution or timer measurer creation.
|
||||||
PISystemTime reset_time() {return t_st;}
|
PISystemTime reset_time() {return t_st;}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void PIBaseTransfer::stopSend() {
|
|||||||
void PIBaseTransfer::stopReceive() {
|
void PIBaseTransfer::stopReceive() {
|
||||||
if (!is_receiving) return;
|
if (!is_receiving) return;
|
||||||
break_ = true;
|
break_ = true;
|
||||||
piCoutObj << "stopReceive()";
|
//piCoutObj << "stopReceive()";
|
||||||
finish_receive(false);
|
finish_receive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
|||||||
diag.received(data.size(), false);
|
diag.received(data.size(), false);
|
||||||
return;
|
return;
|
||||||
} else diag.received(data.size(), true);
|
} else diag.received(data.size(), true);
|
||||||
piCoutObj << "receive" << h.session_id << h.type << h.id;
|
//piCoutObj << "receive" << h.session_id << h.type << h.id;
|
||||||
switch (pt) {
|
switch (pt) {
|
||||||
case pt_Unknown: break;
|
case pt_Unknown: break;
|
||||||
case pt_Data:
|
case pt_Data:
|
||||||
@@ -75,7 +75,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
|||||||
if (rcrc != ccrc) {
|
if (rcrc != ccrc) {
|
||||||
header.id = h.id;
|
header.id = h.id;
|
||||||
sendReply(pt_ReplyInvalid);
|
sendReply(pt_ReplyInvalid);
|
||||||
piCoutObj << "invalid CRC";
|
//piCoutObj << "invalid CRC";
|
||||||
} else {
|
} else {
|
||||||
processData(h.id, data);
|
processData(h.id, data);
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
|||||||
break;
|
break;
|
||||||
case pt_Break:
|
case pt_Break:
|
||||||
break_ = true;
|
break_ = true;
|
||||||
piCoutObj << "BREAK";
|
//piCoutObj << "BREAK";
|
||||||
if (is_receiving) {
|
if (is_receiving) {
|
||||||
stopReceive();
|
stopReceive();
|
||||||
return;
|
return;
|
||||||
@@ -129,7 +129,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
|||||||
if (header.session_id != h.session_id) {
|
if (header.session_id != h.session_id) {
|
||||||
//sendBreak(h.session_id);
|
//sendBreak(h.session_id);
|
||||||
//return;
|
//return;
|
||||||
piCoutObj << "restart receive";
|
//piCoutObj << "restart receive";
|
||||||
finish_receive(false, true);
|
finish_receive(false, true);
|
||||||
} else return;
|
} else return;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
|||||||
replies.fill(pt_Unknown);
|
replies.fill(pt_Unknown);
|
||||||
diag.reset();
|
diag.reset();
|
||||||
diag.start(100);
|
diag.start(100);
|
||||||
piCoutObj << "receiveStarted()";
|
//piCoutObj << "receiveStarted()";
|
||||||
is_receiving = true;
|
is_receiving = true;
|
||||||
break_ = false;
|
break_ = false;
|
||||||
receiveStarted();
|
receiveStarted();
|
||||||
@@ -160,16 +160,16 @@ void PIBaseTransfer::received(PIByteArray data) {
|
|||||||
break;
|
break;
|
||||||
case pt_Pause:
|
case pt_Pause:
|
||||||
if (header.session_id == h.session_id) {
|
if (header.session_id == h.session_id) {
|
||||||
piCout << "receive pause";
|
//piCout << "receive pause";
|
||||||
if (!is_pause && pause_tm.elapsed_s() < timeout_/10) {
|
if (!is_pause && pause_tm.elapsed_s() < timeout_/10) {
|
||||||
piCout << "resume";
|
//piCout << "resume";
|
||||||
sendReply(pt_Start);
|
sendReply(pt_Start);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!is_pause) paused();
|
if (!is_pause) paused();
|
||||||
is_pause = true;
|
is_pause = true;
|
||||||
if (is_receiving && pause_tm.elapsed_m() > 40) {
|
if (is_receiving && pause_tm.elapsed_m() > 40) {
|
||||||
piCout << "send pause";
|
//piCout << "send pause";
|
||||||
sendReply(pt_Pause);
|
sendReply(pt_Pause);
|
||||||
}
|
}
|
||||||
if (is_sending) send_tm.reset();
|
if (is_sending) send_tm.reset();
|
||||||
@@ -203,7 +203,7 @@ bool PIBaseTransfer::send_process() {
|
|||||||
piMSleep(1);
|
piMSleep(1);
|
||||||
if (is_pause) {
|
if (is_pause) {
|
||||||
piMSleep(40);
|
piMSleep(40);
|
||||||
piCout << "send pause";
|
//piCout << "send pause";
|
||||||
sendReply(pt_Pause);
|
sendReply(pt_Pause);
|
||||||
if (pause_tm.elapsed_s() > timeout())return finish_send(false);
|
if (pause_tm.elapsed_s() > timeout())return finish_send(false);
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ bool PIBaseTransfer::send_process() {
|
|||||||
}
|
}
|
||||||
if (is_pause) {
|
if (is_pause) {
|
||||||
piMSleep(40);
|
piMSleep(40);
|
||||||
piCout << "send pause";
|
//piCout << "send pause";
|
||||||
sendReply(pt_Pause);
|
sendReply(pt_Pause);
|
||||||
if (pause_tm.elapsed_s() > timeout())return finish_send(false);
|
if (pause_tm.elapsed_s() > timeout())return finish_send(false);
|
||||||
else continue;
|
else continue;
|
||||||
@@ -240,7 +240,7 @@ bool PIBaseTransfer::send_process() {
|
|||||||
prev_chk = chk;
|
prev_chk = chk;
|
||||||
if (chk > 0) {
|
if (chk > 0) {
|
||||||
if (tm2.elapsed_s() > timeout_ / 10.) {
|
if (tm2.elapsed_s() > timeout_ / 10.) {
|
||||||
piCoutObj << "recovery packet" << chk;
|
//piCoutObj << "recovery packet" << chk;
|
||||||
if (send_queue >= packets_count) {
|
if (send_queue >= packets_count) {
|
||||||
piMSleep(10);
|
piMSleep(10);
|
||||||
continue;
|
continue;
|
||||||
@@ -270,7 +270,7 @@ int PIBaseTransfer::checkSession() {
|
|||||||
if (replies[i] != pt_ReplySuccess) return i;
|
if (replies[i] != pt_ReplySuccess) return i;
|
||||||
}
|
}
|
||||||
if (miss > 0) {
|
if (miss > 0) {
|
||||||
piCoutObj << "missing" << miss << "packets";
|
//piCoutObj << "missing" << miss << "packets";
|
||||||
return -miss;
|
return -miss;
|
||||||
} else return 0;
|
} else return 0;
|
||||||
}
|
}
|
||||||
@@ -289,12 +289,12 @@ void PIBaseTransfer::buildSession(PIVector<Part> parts) {
|
|||||||
for (int i = 0; i < parts.size_s(); i++) {
|
for (int i = 0; i < parts.size_s(); i++) {
|
||||||
state_string = "calculating parts ... " + PIString::fromNumber(i) + " of " + PIString::fromNumber(parts.size());
|
state_string = "calculating parts ... " + PIString::fromNumber(i) + " of " + PIString::fromNumber(parts.size());
|
||||||
fi.id = parts[i].id;
|
fi.id = parts[i].id;
|
||||||
piCout << fi.id << state_string;
|
//piCout << fi.id << state_string;
|
||||||
bytes_all += parts[i].size;
|
bytes_all += parts[i].size;
|
||||||
//fi.size = fi.entry.size;
|
//fi.size = fi.entry.size;
|
||||||
fi.start = 0;
|
fi.start = 0;
|
||||||
llong rest = parts[i].size - (packet_size - cur_size);
|
llong rest = parts[i].size - (packet_size - cur_size);
|
||||||
piCout << i << fi.size << rest << bytes_all;
|
//piCout << i << fi.size << rest << bytes_all;
|
||||||
if (rest <= 0) {
|
if (rest <= 0) {
|
||||||
fi.size = parts[i].size;
|
fi.size = parts[i].size;
|
||||||
lfi << fi;
|
lfi << fi;
|
||||||
@@ -334,7 +334,7 @@ void PIBaseTransfer::buildSession(PIVector<Part> parts) {
|
|||||||
|
|
||||||
|
|
||||||
void PIBaseTransfer::sendBreak(int session_id) {
|
void PIBaseTransfer::sendBreak(int session_id) {
|
||||||
piCoutObj << "sendBreak";
|
//piCoutObj << "sendBreak";
|
||||||
uint psid = header.session_id;
|
uint psid = header.session_id;
|
||||||
header.session_id = session_id;
|
header.session_id = session_id;
|
||||||
sendReply(pt_Break);
|
sendReply(pt_Break);
|
||||||
@@ -343,7 +343,7 @@ void PIBaseTransfer::sendBreak(int session_id) {
|
|||||||
|
|
||||||
|
|
||||||
void PIBaseTransfer::sendReply(PacketType reply) {
|
void PIBaseTransfer::sendReply(PacketType reply) {
|
||||||
piCoutObj << "sendReply" << reply;
|
//piCoutObj << "sendReply" << reply;
|
||||||
header.type = reply;
|
header.type = reply;
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba << header;
|
ba << header;
|
||||||
@@ -379,7 +379,7 @@ bool PIBaseTransfer::getStartRequest() {
|
|||||||
|
|
||||||
|
|
||||||
void PIBaseTransfer::processData(int id, PIByteArray & data) {
|
void PIBaseTransfer::processData(int id, PIByteArray & data) {
|
||||||
piCoutObj << "received packet" << id << ", size" << data.size();
|
//piCoutObj << "received packet" << id << ", size" << data.size();
|
||||||
if (id < 1 || id > replies.size_s()) return;
|
if (id < 1 || id > replies.size_s()) return;
|
||||||
if (!session[id - 1].isEmpty()) {
|
if (!session[id - 1].isEmpty()) {
|
||||||
header.id = id;
|
header.id = id;
|
||||||
@@ -402,7 +402,7 @@ void PIBaseTransfer::processData(int id, PIByteArray & data) {
|
|||||||
data >> ba;
|
data >> ba;
|
||||||
//fi.fsize = ba.size();
|
//fi.fsize = ba.size();
|
||||||
bytes_cur += fi.size;
|
bytes_cur += fi.size;
|
||||||
piCoutObj << "recv" << fi;
|
//piCoutObj << "recv" << fi;
|
||||||
session[id - 1] << fi;
|
session[id - 1] << fi;
|
||||||
state_string = "receiving...";
|
state_string = "receiving...";
|
||||||
receivePart(fi, ba, pheader);
|
receivePart(fi, ba, pheader);
|
||||||
@@ -419,13 +419,13 @@ PIByteArray PIBaseTransfer::build_packet(int id) {
|
|||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
header.id = id + 1;
|
header.id = id + 1;
|
||||||
header.type = pt_Data;
|
header.type = pt_Data;
|
||||||
piCoutObj << "session id" << header.session_id;
|
//piCoutObj << "session id" << header.session_id;
|
||||||
//ret << header;
|
//ret << header;
|
||||||
ret.append(customHeader());
|
ret.append(customHeader());
|
||||||
for (int i = 0; i < session[id].size_s(); i++) {
|
for (int i = 0; i < session[id].size_s(); i++) {
|
||||||
Part fi = session[id][i];
|
Part fi = session[id][i];
|
||||||
ret << fi;
|
ret << fi;
|
||||||
piCout << "biuld" << fi;
|
//piCout << "biuld" << fi;
|
||||||
ba = buildPacket(fi);
|
ba = buildPacket(fi);
|
||||||
bytes_cur += ba.size();
|
bytes_cur += ba.size();
|
||||||
if (ba.size() != fi.size) piCoutObj << "***error while build packet, wrong part size";
|
if (ba.size() != fi.size) piCoutObj << "***error while build packet, wrong part size";
|
||||||
@@ -434,7 +434,7 @@ PIByteArray PIBaseTransfer::build_packet(int id) {
|
|||||||
header.crc = crc.calculate(ret);
|
header.crc = crc.calculate(ret);
|
||||||
PIByteArray hdr; hdr << header;
|
PIByteArray hdr; hdr << header;
|
||||||
ret.insert(0, hdr);
|
ret.insert(0, hdr);
|
||||||
piCoutObj << "Packet" << header.id << ret.size();
|
//piCoutObj << "Packet" << header.id << ret.size();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,7 +443,7 @@ bool PIBaseTransfer::finish_send(bool ok) {
|
|||||||
is_sending = false;
|
is_sending = false;
|
||||||
if (ok) state_string = "send done";
|
if (ok) state_string = "send done";
|
||||||
else state_string = "send failed";
|
else state_string = "send failed";
|
||||||
piCoutObj << state_string << PIString::readableSize(bytes_all);
|
//piCoutObj << state_string << PIString::readableSize(bytes_all);
|
||||||
header.id = 0;
|
header.id = 0;
|
||||||
if (!ok) sendBreak(header.session_id);
|
if (!ok) sendBreak(header.session_id);
|
||||||
else sendReply(pt_ReplySuccess);
|
else sendReply(pt_ReplySuccess);
|
||||||
@@ -458,7 +458,7 @@ void PIBaseTransfer::finish_receive(bool ok, bool quet) {
|
|||||||
is_receiving = false;
|
is_receiving = false;
|
||||||
if (ok) state_string = "receive done";
|
if (ok) state_string = "receive done";
|
||||||
else state_string = "receive failed";
|
else state_string = "receive failed";
|
||||||
piCoutObj << state_string << PIString::readableSize(bytes_all);
|
//piCoutObj << state_string << PIString::readableSize(bytes_all);
|
||||||
if (!ok && !quet) sendBreak(header.session_id);
|
if (!ok && !quet) sendBreak(header.session_id);
|
||||||
receiveFinished(ok);
|
receiveFinished(ok);
|
||||||
diag.stop();
|
diag.stop();
|
||||||
@@ -469,7 +469,7 @@ void PIBaseTransfer::finish_receive(bool ok, bool quet) {
|
|||||||
void PIBaseTransfer::diagChanged(PIDiagnostics::Quality new_quality, PIDiagnostics::Quality old_quality) {
|
void PIBaseTransfer::diagChanged(PIDiagnostics::Quality new_quality, PIDiagnostics::Quality old_quality) {
|
||||||
if (is_receiving) {
|
if (is_receiving) {
|
||||||
if (new_quality == PIDiagnostics::Failure) {
|
if (new_quality == PIDiagnostics::Failure) {
|
||||||
piCout << "disconnected!";
|
//piCout << "disconnected!";
|
||||||
break_ = true;
|
break_ = true;
|
||||||
is_receiving = false;
|
is_receiving = false;
|
||||||
state_string = "receive failed";
|
state_string = "receive failed";
|
||||||
|
|||||||
@@ -274,9 +274,9 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
|
|||||||
# endif
|
# endif
|
||||||
for (int i = 0; i < cnt; ++i) {
|
for (int i = 0; i < cnt; ++i) {
|
||||||
l << PIFile::fileInfo(dp + PIString(list[i]->d_name));
|
l << PIFile::fileInfo(dp + PIString(list[i]->d_name));
|
||||||
delete list[i];
|
free(list[i]);
|
||||||
}
|
}
|
||||||
delete list;
|
free(list);
|
||||||
#endif
|
#endif
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -532,13 +532,14 @@ int PIEthernet::read(void * read_to, int max_size) {
|
|||||||
case UDP:
|
case UDP:
|
||||||
memset(&PRIVATE->raddr_, 0, sizeof(PRIVATE->raddr_));
|
memset(&PRIVATE->raddr_, 0, sizeof(PRIVATE->raddr_));
|
||||||
rs = ethRecvfrom(sock, read_to, max_size, 0, (sockaddr*)&PRIVATE->raddr_);
|
rs = ethRecvfrom(sock, read_to, max_size, 0, (sockaddr*)&PRIVATE->raddr_);
|
||||||
//piCout << "eth" << path() << "read return" << rs << errorString();
|
|
||||||
if (rs > 0) {
|
if (rs > 0) {
|
||||||
port_r = ntohs(PRIVATE->raddr_.sin_port);
|
port_r = ntohs(PRIVATE->raddr_.sin_port);
|
||||||
ip_r = PIStringAscii(inet_ntoa(PRIVATE->raddr_.sin_addr));
|
ip_r = PIStringAscii(inet_ntoa(PRIVATE->raddr_.sin_addr));
|
||||||
|
//piCoutObj << "read from" << ip_r << ":" << port_r << rs << "bytes";
|
||||||
//piCout << "received from" << lastReadAddress();
|
//piCout << "received from" << lastReadAddress();
|
||||||
received(read_to, rs);
|
received(read_to, rs);
|
||||||
}
|
}
|
||||||
|
//else piCoutObj << "read returt" << rs << ", error" << ethErrorString();
|
||||||
return rs;
|
return rs;
|
||||||
//return ::read(sock, read_to, max_size);
|
//return ::read(sock, read_to, max_size);
|
||||||
default: break;
|
default: break;
|
||||||
@@ -582,7 +583,7 @@ int PIEthernet::write(const void * data, int max_size) {
|
|||||||
/*if (params[PIEthernet::Broadcast]) PRIVATE->saddr_.sin_addr.s_addr = INADDR_BROADCAST;
|
/*if (params[PIEthernet::Broadcast]) PRIVATE->saddr_.sin_addr.s_addr = INADDR_BROADCAST;
|
||||||
else*/ PRIVATE->saddr_.sin_addr.s_addr = inet_addr(ip_s.dataAscii());
|
else*/ PRIVATE->saddr_.sin_addr.s_addr = inet_addr(ip_s.dataAscii());
|
||||||
PRIVATE->saddr_.sin_family = AF_INET;
|
PRIVATE->saddr_.sin_family = AF_INET;
|
||||||
//piCout << "[PIEth] write to" << ip_s << ":" << port_s << "socket" << sock_s << max_size << "bytes ...";
|
//piCoutObj << "write to" << ip_s << ":" << port_s << "socket" << sock_s << max_size << "bytes ...";
|
||||||
return ethSendto(sock_s, data, max_size, 0, (sockaddr * )&PRIVATE->saddr_, sizeof(PRIVATE->saddr_));
|
return ethSendto(sock_s, data, max_size, 0, (sockaddr * )&PRIVATE->saddr_, sizeof(PRIVATE->saddr_));
|
||||||
//piCout << "[PIEth] write to" << ip_s << ":" << port_s << "ok";
|
//piCout << "[PIEth] write to" << ip_s << ":" << port_s << "ok";
|
||||||
case TCP_Client:
|
case TCP_Client:
|
||||||
@@ -819,7 +820,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
|||||||
ifc.ifc_buf = new char[ifc.ifc_len];
|
ifc.ifc_buf = new char[ifc.ifc_len];
|
||||||
if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
|
if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
|
||||||
piCout << "[PIEthernet] Can`t get interfaces:" << errorString();
|
piCout << "[PIEthernet] Can`t get interfaces:" << errorString();
|
||||||
delete ifc.ifc_buf;
|
delete[] ifc.ifc_buf;
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
int icnt = ifc.ifc_len / sizeof(ifreq);
|
int icnt = ifc.ifc_len / sizeof(ifreq);
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
|
|||||||
if (!info.perm_user.write) attr |= FILE_ATTRIBUTE_READONLY;
|
if (!info.perm_user.write) attr |= FILE_ATTRIBUTE_READONLY;
|
||||||
if (SetFileAttributes((LPCTSTR)(fp.data()), attr) == 0) {
|
if (SetFileAttributes((LPCTSTR)(fp.data()), attr) == 0) {
|
||||||
piCout << "[PIFile] applyFileInfo: \"SetFileAttributes\" error:" << errorString();
|
piCout << "[PIFile] applyFileInfo: \"SetFileAttributes\" error:" << errorString();
|
||||||
return false;
|
//return false;
|
||||||
}
|
}
|
||||||
HANDLE hFile = 0;
|
HANDLE hFile = 0;
|
||||||
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
|
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
@@ -515,11 +515,11 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
|
|||||||
if (info.perm_other.exec) mode |= S_IXOTH;
|
if (info.perm_other.exec) mode |= S_IXOTH;
|
||||||
if (chmod(fp.data(), mode) != 0) {
|
if (chmod(fp.data(), mode) != 0) {
|
||||||
piCout << "[PIFile] applyFileInfo: \"chmod\" error:" << errorString();
|
piCout << "[PIFile] applyFileInfo: \"chmod\" error:" << errorString();
|
||||||
return false;
|
//return false;
|
||||||
}
|
}
|
||||||
if (chown(fp.data(), info.id_user, info.id_group) != 0) {
|
if (chown(fp.data(), info.id_user, info.id_group) != 0) {
|
||||||
piCout << "[PIFile] applyFileInfo: \"chown\" error:" << errorString();
|
piCout << "[PIFile] applyFileInfo: \"chown\" error:" << errorString();
|
||||||
return false;
|
//return false;
|
||||||
}
|
}
|
||||||
struct timeval tm[2];
|
struct timeval tm[2];
|
||||||
PISystemTime st = info.time_access.toSystemTime();
|
PISystemTime st = info.time_access.toSystemTime();
|
||||||
@@ -530,7 +530,7 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
|
|||||||
tm[1].tv_usec = st.nanoseconds / 1000;
|
tm[1].tv_usec = st.nanoseconds / 1000;
|
||||||
if (utimes(fp.data(), tm) != 0) {
|
if (utimes(fp.data(), tm) != 0) {
|
||||||
piCout << "[PIFile] applyFileInfo: \"utimes\" error:" << errorString();
|
piCout << "[PIFile] applyFileInfo: \"utimes\" error:" << errorString();
|
||||||
return false;
|
//return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ PIByteArray PIIODevice::readForTime(double timeout_ms) {
|
|||||||
if (ret <= 0) msleep(1);
|
if (ret <= 0) msleep(1);
|
||||||
else str.append(td, ret);
|
else str.append(td, ret);
|
||||||
}
|
}
|
||||||
delete td;
|
delete[] td;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ PIPeer::PeerData::PeerData(const PIString & n): PIObject(n) {
|
|||||||
|
|
||||||
|
|
||||||
PIPeer::PeerData::~PeerData() {
|
PIPeer::PeerData::~PeerData() {
|
||||||
t.stop();
|
dt_in.stop();
|
||||||
|
dt_out.stop();
|
||||||
|
t.stop(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -55,6 +57,7 @@ void PIPeer::PeerData::dtThread() {
|
|||||||
|
|
||||||
|
|
||||||
bool PIPeer::PeerData::send(const PIByteArray & d) {
|
bool PIPeer::PeerData::send(const PIByteArray & d) {
|
||||||
|
piCout << "send ..." << t.isRunning();
|
||||||
if (t.isRunning()) return false;
|
if (t.isRunning()) return false;
|
||||||
data = d;
|
data = d;
|
||||||
t.startOnce();
|
t.startOnce();
|
||||||
@@ -335,7 +338,7 @@ bool PIPeer::sendInternal(const PIString & to, const PIByteArray & data) {
|
|||||||
}
|
}
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba << int(4) << self_info.name << to << int(0) << data;
|
ba << int(4) << self_info.name << to << int(0) << data;
|
||||||
//piCoutObj << "sendInternal" << to << data.size_s() << int(data.front());
|
piCoutObj << "sendInternal to" << to << data.size_s() << int(data.front());
|
||||||
if (!sendToNeighbour(dp, ba)) return false;
|
if (!sendToNeighbour(dp, ba)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -355,7 +358,7 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
|||||||
PIString from, to;
|
PIString from, to;
|
||||||
ba >> type;
|
ba >> type;
|
||||||
PIMutexLocker locker(eth_mutex);
|
PIMutexLocker locker(eth_mutex);
|
||||||
//piCout << "[PIPeer \"" + name_ + "\"] Received packet" << type;
|
piCoutObj << "received data from" << from << "packet" << type;
|
||||||
if (type == 5) { // ping request
|
if (type == 5) { // ping request
|
||||||
PIString addr;
|
PIString addr;
|
||||||
PISystemTime time;
|
PISystemTime time;
|
||||||
@@ -456,7 +459,7 @@ bool PIPeer::mbcastRead(uchar * data, int size) {
|
|||||||
if (type <= 0 || type >= 4) return true;
|
if (type <= 0 || type >= 4) return true;
|
||||||
PeerInfo pi;
|
PeerInfo pi;
|
||||||
ba >> pi.name;
|
ba >> pi.name;
|
||||||
//piCout << "read type" << type << "from" << pi.name;
|
piCoutObj << "received mb from" << pi.name << "packet" << type;
|
||||||
if (pi.name == self_info.name) return true;
|
if (pi.name == self_info.name) return true;
|
||||||
PIMutexLocker locker(mc_mutex);
|
PIMutexLocker locker(mc_mutex);
|
||||||
diag_s.received(size);
|
diag_s.received(size);
|
||||||
@@ -743,6 +746,11 @@ void PIPeer::checkNetwork() {
|
|||||||
PIEthernet::InterfaceList ifaces = PIEthernet::interfaces();
|
PIEthernet::InterfaceList ifaces = PIEthernet::interfaces();
|
||||||
if (prev_ifaces == ifaces) return;
|
if (prev_ifaces == ifaces) return;
|
||||||
prev_ifaces = ifaces;
|
prev_ifaces = ifaces;
|
||||||
|
reinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIPeer::reinit() {
|
||||||
PIMutexLocker mbl(mc_mutex);
|
PIMutexLocker mbl(mc_mutex);
|
||||||
PIMutexLocker ethl(eth_mutex);
|
PIMutexLocker ethl(eth_mutex);
|
||||||
PIMutexLocker pl(peers_mutex);
|
PIMutexLocker pl(peers_mutex);
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ public:
|
|||||||
const PeerInfo & selfInfo() const {return self_info;}
|
const PeerInfo & selfInfo() const {return self_info;}
|
||||||
const PIMap<PIString, PIVector<PeerInfo * > > & _peerMap() const {return addresses_map;}
|
const PIMap<PIString, PIVector<PeerInfo * > > & _peerMap() const {return addresses_map;}
|
||||||
|
|
||||||
|
void reinit();
|
||||||
void lock() {peers_mutex.lock();}
|
void lock() {peers_mutex.lock();}
|
||||||
void unlock() {peers_mutex.unlock();}
|
void unlock() {peers_mutex.unlock();}
|
||||||
|
|
||||||
|
|||||||
@@ -123,19 +123,18 @@ bool PIThread::start(int timer_delay) {
|
|||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
# ifndef ANDROID
|
# ifndef ANDROID
|
||||||
pthread_attr_setschedparam(&attr, &sparam);
|
//pthread_attr_setschedparam(&attr, &sparam);
|
||||||
# endif
|
# endif
|
||||||
if (pthread_create(&thread, &attr, thread_function, this) == 0) {
|
int ret = pthread_create(&thread, &attr, thread_function, this);
|
||||||
setPriority(priority_);
|
pthread_attr_destroy(&attr);
|
||||||
running_ = true;
|
if (ret == 0) {
|
||||||
return true;
|
|
||||||
#else
|
#else
|
||||||
thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function, this, 0, 0);
|
thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function, this, 0, 0);
|
||||||
if (thread != 0) {
|
if (thread != 0) {
|
||||||
|
#endif
|
||||||
setPriority(priority_);
|
setPriority(priority_);
|
||||||
running_ = true;
|
running_ = true;
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
thread = 0;
|
thread = 0;
|
||||||
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
||||||
@@ -151,19 +150,18 @@ bool PIThread::startOnce() {
|
|||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
# ifndef ANDROID
|
# ifndef ANDROID
|
||||||
pthread_attr_setschedparam(&attr, &sparam);
|
//pthread_attr_setschedparam(&attr, &sparam);
|
||||||
# endif
|
# endif
|
||||||
if (pthread_create(&thread, &attr, thread_function_once, this) == 0) {
|
int ret = pthread_create(&thread, &attr, thread_function_once, this);
|
||||||
setPriority(priority_);
|
pthread_attr_destroy(&attr);
|
||||||
running_ = true;
|
if (ret == 0) {
|
||||||
return true;
|
|
||||||
#else
|
#else
|
||||||
thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function_once, this, 0, 0);
|
thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function_once, this, 0, 0);
|
||||||
if (thread != 0) {
|
if (thread != 0) {
|
||||||
|
#endif
|
||||||
setPriority(priority_);
|
setPriority(priority_);
|
||||||
running_ = true;
|
running_ = true;
|
||||||
return false;
|
return true;
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
thread = 0;
|
thread = 0;
|
||||||
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
||||||
@@ -180,7 +178,9 @@ void PIThread::terminate() {
|
|||||||
pthread_kill(thread, SIGKILL);
|
pthread_kill(thread, SIGKILL);
|
||||||
# else
|
# else
|
||||||
//pthread_kill(thread, SIGKILL);
|
//pthread_kill(thread, SIGKILL);
|
||||||
|
void * ret(0);
|
||||||
pthread_cancel(thread);
|
pthread_cancel(thread);
|
||||||
|
pthread_join(thread, &ret);
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
TerminateThread(thread, 0);
|
TerminateThread(thread, 0);
|
||||||
@@ -230,6 +230,9 @@ void * PIThread::thread_function(void * t) {
|
|||||||
if (ct.lockRun) ct.mutex_.unlock();
|
if (ct.lockRun) ct.mutex_.unlock();
|
||||||
ct.terminating = ct.running_ = false;
|
ct.terminating = ct.running_ = false;
|
||||||
//cout << "thread " << t << " exiting ... " << endl;
|
//cout << "thread " << t << " exiting ... " << endl;
|
||||||
|
#ifndef WINDOWS
|
||||||
|
pthread_detach(ct.thread);
|
||||||
|
#endif
|
||||||
ct.thread = 0;
|
ct.thread = 0;
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
@@ -261,6 +264,9 @@ void * PIThread::thread_function_once(void * t) {
|
|||||||
ct.end();
|
ct.end();
|
||||||
ct.terminating = ct.running_ = false;
|
ct.terminating = ct.running_ = false;
|
||||||
//cout << "thread " << t << " exiting ... " << endl;
|
//cout << "thread " << t << " exiting ... " << endl;
|
||||||
|
#ifndef WINDOWS
|
||||||
|
pthread_detach(ct.thread);
|
||||||
|
#endif
|
||||||
ct.thread = 0;
|
ct.thread = 0;
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
@@ -303,7 +309,7 @@ int PIThread::priority2System(PIThread::Priority p) {
|
|||||||
void PIThread::setPriority(PIThread::Priority prior) {
|
void PIThread::setPriority(PIThread::Priority prior) {
|
||||||
priority_ = prior;
|
priority_ = prior;
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
if (!running_ && thread != 0) return;
|
if (!running_ && (thread != 0)) return;
|
||||||
pthread_getschedparam(thread, &policy_, &sparam);
|
pthread_getschedparam(thread, &policy_, &sparam);
|
||||||
sparam.
|
sparam.
|
||||||
# ifndef LINUX
|
# ifndef LINUX
|
||||||
@@ -314,7 +320,7 @@ void PIThread::setPriority(PIThread::Priority prior) {
|
|||||||
= priority2System(priority_);
|
= priority2System(priority_);
|
||||||
pthread_setschedparam(thread, policy_, &sparam);
|
pthread_setschedparam(thread, policy_, &sparam);
|
||||||
#else
|
#else
|
||||||
if (!running_ && thread != 0) return;
|
if (!running_ && (thread != 0)) return;
|
||||||
SetThreadPriority(thread, priority2System(priority_));
|
SetThreadPriority(thread, priority2System(priority_));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,8 @@
|
|||||||
_PITimerBase::_PITimerBase() {
|
_PITimerBase::_PITimerBase() {
|
||||||
interval_ = deferred_delay = 0.;
|
interval_ = deferred_delay = 0.;
|
||||||
running_ = deferred_ = deferred_mode = false;
|
running_ = deferred_ = deferred_mode = false;
|
||||||
|
tfunc = 0;
|
||||||
|
parent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -188,6 +190,10 @@ bool _PITimerImp_Thread::threadFunc() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
st_time += st_inc;
|
st_time += st_inc;
|
||||||
|
if (!parent->isPIObject()) {
|
||||||
|
piCout << "Achtung! PITimer \"parent\" is not PIObject!";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
tfunc(parent);
|
tfunc(parent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Daemon::Remote::Remote(const PIString & n): PIThread() {
|
|||||||
|
|
||||||
Daemon::Remote::~Remote() {
|
Daemon::Remote::~Remote() {
|
||||||
ft.stop();
|
ft.stop();
|
||||||
waitForFinish(1000);
|
stop(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -283,6 +283,7 @@ void Daemon::fillInfoTile(const Daemon::HostInfo & hi) {
|
|||||||
|
|
||||||
|
|
||||||
void Daemon::tileEvent(PIScreenTile * t, TileEvent e) {
|
void Daemon::tileEvent(PIScreenTile * t, TileEvent e) {
|
||||||
|
PIMutexLocker ml(remote_mutex);
|
||||||
if (t == list_daemons) {
|
if (t == list_daemons) {
|
||||||
if (e.type == TileList::RowPressed) {
|
if (e.type == TileList::RowPressed) {
|
||||||
connectToDaemon(list_daemons->content[e.data.toInt()].first);
|
connectToDaemon(list_daemons->content[e.data.toInt()].first);
|
||||||
@@ -332,6 +333,7 @@ void Daemon::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
|
|
||||||
void Daemon::fmKeyEvent(PIKbdListener::KeyEvent key) {
|
void Daemon::fmKeyEvent(PIKbdListener::KeyEvent key) {
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
|
PIMutexLocker ml(remote_mutex);
|
||||||
//Remote * r = remotes.value(conn_name);
|
//Remote * r = remotes.value(conn_name);
|
||||||
//piCout << key.key << key.modifiers;
|
//piCout << key.key << key.modifiers;
|
||||||
switch (key.key) {
|
switch (key.key) {
|
||||||
@@ -448,6 +450,7 @@ void Daemon::peerConnected(const PIString & name) {
|
|||||||
CONNECTU(r, receiveFinished, this, closeFileDialog)
|
CONNECTU(r, receiveFinished, this, closeFileDialog)
|
||||||
CONNECTU(r, sendFinished, this, closeFileDialog)
|
CONNECTU(r, sendFinished, this, closeFileDialog)
|
||||||
CONNECTU(r, removeFinished, this, filesRemoved)
|
CONNECTU(r, removeFinished, this, filesRemoved)
|
||||||
|
PIMutexLocker ml(remote_mutex);
|
||||||
remotes.insert(name, r);
|
remotes.insert(name, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,6 +459,7 @@ void Daemon::peerDisconnected(const PIString & name) {
|
|||||||
if (name == conn_name) {
|
if (name == conn_name) {
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
|
PIMutexLocker ml(remote_mutex);
|
||||||
Remote * dt = remotes.value(name, 0);
|
Remote * dt = remotes.value(name, 0);
|
||||||
if (!dt) return;
|
if (!dt) return;
|
||||||
if (tile_file_progress->ft == &(dt->ft)) {
|
if (tile_file_progress->ft == &(dt->ft)) {
|
||||||
@@ -472,6 +476,7 @@ void Daemon::filesReceived(const PIString & name, bool ok) {
|
|||||||
|
|
||||||
|
|
||||||
void Daemon::filesRemoved(const PIString & name, const PIString & dir) {
|
void Daemon::filesRemoved(const PIString & name, const PIString & dir) {
|
||||||
|
PIMutexLocker ml(remote_mutex);
|
||||||
Remote * r = remotes.value(name, 0);
|
Remote * r = remotes.value(name, 0);
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
if (r->dir_my.absolutePath() != dir) return;
|
if (r->dir_my.absolutePath() != dir) return;
|
||||||
@@ -500,8 +505,9 @@ void Daemon::closeFileDialog(const PIString & name, bool ok) {
|
|||||||
void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||||
//if (conn_name != from) return;
|
//if (conn_name != from) return;
|
||||||
if (data.size() < 4) return;
|
if (data.size() < 4) return;
|
||||||
|
PIMutexLocker ml(remote_mutex);
|
||||||
PIByteArray ba(data), rba;
|
PIByteArray ba(data), rba;
|
||||||
Remote * r(0);
|
Remote * r = remotes.value(from);
|
||||||
PIString dir;
|
PIString dir;
|
||||||
int type; ba >> type;
|
int type; ba >> type;
|
||||||
//piCout << "rec from " << from << type;
|
//piCout << "rec from " << from << type;
|
||||||
@@ -511,7 +517,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
rba << int(ReplyHostInfo) << info_my;
|
rba << int(ReplyHostInfo) << info_my;
|
||||||
break;
|
break;
|
||||||
case RequestChangeDir:
|
case RequestChangeDir:
|
||||||
r = remotes.value(from);
|
|
||||||
if (!r) break;
|
if (!r) break;
|
||||||
ba >> dir;
|
ba >> dir;
|
||||||
r->dir_my.cd(dir);
|
r->dir_my.cd(dir);
|
||||||
@@ -526,7 +531,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
fillInfoTile(info_other);
|
fillInfoTile(info_other);
|
||||||
break;
|
break;
|
||||||
case ReplyChangeDir:
|
case ReplyChangeDir:
|
||||||
r = remotes.value(from);
|
|
||||||
if (!r) break;
|
if (!r) break;
|
||||||
{
|
{
|
||||||
PIVector<PIFile::FileInfo> fil;
|
PIVector<PIFile::FileInfo> fil;
|
||||||
@@ -538,7 +542,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CopyFiles:
|
case CopyFiles:
|
||||||
r = remotes.value(from);
|
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
if (r->isRunning()) return;
|
if (r->isRunning()) return;
|
||||||
{
|
{
|
||||||
@@ -549,7 +552,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RemoveFiles:
|
case RemoveFiles:
|
||||||
r = remotes.value(from);
|
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
if (r->isRunning()) return;
|
if (r->isRunning()) return;
|
||||||
{
|
{
|
||||||
@@ -561,7 +563,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MkDir:
|
case MkDir:
|
||||||
r = remotes.value(from);
|
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
{
|
{
|
||||||
PIString dn;
|
PIString dn;
|
||||||
@@ -572,7 +573,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FileTransfer:
|
case FileTransfer:
|
||||||
r = remotes.value(from);
|
|
||||||
if (r) r->received(ba);
|
if (r) r->received(ba);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@@ -625,6 +625,9 @@ void Daemon::makeOtherHostInfo() {
|
|||||||
|
|
||||||
void Daemon::requestChDir(const PIString & d) {
|
void Daemon::requestChDir(const PIString & d) {
|
||||||
if (d.isEmpty()) return;
|
if (d.isEmpty()) return;
|
||||||
|
Remote * r = remotes.value(conn_name, 0);
|
||||||
|
if (d.isEmpty()) return;
|
||||||
|
if (!r) return;
|
||||||
fm.remoteSaveDir();
|
fm.remoteSaveDir();
|
||||||
fm.readingRemote();
|
fm.readingRemote();
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ private:
|
|||||||
mutable PIStringList available_daemons;
|
mutable PIStringList available_daemons;
|
||||||
PITimer timer;
|
PITimer timer;
|
||||||
PIString conn_name;
|
PIString conn_name;
|
||||||
|
PIMutex remote_mutex;
|
||||||
PIMap<int, PIString> dnames;
|
PIMap<int, PIString> dnames;
|
||||||
PIMap<PIString, Remote*> remotes;
|
PIMap<PIString, Remote*> remotes;
|
||||||
PISystemMonitor sys_mon_other;
|
PISystemMonitor sys_mon_other;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ FileManager::TileDir::TileDir(): TileList() {
|
|||||||
|
|
||||||
PIStringList FileManager::TileDir::selectedNames() const {
|
PIStringList FileManager::TileDir::selectedNames() const {
|
||||||
PIStringList ret;
|
PIStringList ret;
|
||||||
|
PIMutexLocker ml(e_mutex);
|
||||||
PIVector<int> sind = selected.toVector();
|
PIVector<int> sind = selected.toVector();
|
||||||
piForeachC (int i, sind)
|
piForeachC (int i, sind)
|
||||||
ret << entries[i].name();
|
ret << entries[i].name();
|
||||||
@@ -67,6 +68,9 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
pass = true;
|
pass = true;
|
||||||
break;
|
break;
|
||||||
case PIKbdListener::Return:
|
case PIKbdListener::Return:
|
||||||
|
{
|
||||||
|
e_mutex.lock();
|
||||||
|
bool ud = false;
|
||||||
if (cur < entries.size_s() && cur >= 0) {
|
if (cur < entries.size_s() && cur >= 0) {
|
||||||
if (!remote) {
|
if (!remote) {
|
||||||
//piCout << entries[cur];
|
//piCout << entries[cur];
|
||||||
@@ -77,11 +81,14 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
cur = cp.first;
|
cur = cp.first;
|
||||||
offset = cp.second;
|
offset = cp.second;
|
||||||
selected.clear();
|
selected.clear();
|
||||||
updateDir();
|
ud = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pass = true;
|
pass = true;
|
||||||
}
|
}
|
||||||
|
e_mutex.unlock();
|
||||||
|
if (ud) updateDir();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (remote && pass) {
|
if (remote && pass) {
|
||||||
@@ -103,6 +110,7 @@ void FileManager::TileDir::unlock() {
|
|||||||
|
|
||||||
|
|
||||||
void FileManager::TileDir::showReading() {
|
void FileManager::TileDir::showReading() {
|
||||||
|
PIMutexLocker ml(e_mutex);
|
||||||
cur = -1;
|
cur = -1;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
entries.clear();
|
entries.clear();
|
||||||
@@ -112,6 +120,7 @@ void FileManager::TileDir::showReading() {
|
|||||||
|
|
||||||
|
|
||||||
void FileManager::TileDir::setContent(const PIVector<PIFile::FileInfo> & l) {
|
void FileManager::TileDir::setContent(const PIVector<PIFile::FileInfo> & l) {
|
||||||
|
PIMutexLocker ml(e_mutex);
|
||||||
PIVector<PIFile::FileInfo> el = dir.entries(), fl, dl;
|
PIVector<PIFile::FileInfo> el = dir.entries(), fl, dl;
|
||||||
entries.clear();
|
entries.clear();
|
||||||
if (l.isEmpty()) {
|
if (l.isEmpty()) {
|
||||||
@@ -155,6 +164,7 @@ void FileManager::TileDir::updateDir() {
|
|||||||
void FileManager::TileDir::buildNames() {
|
void FileManager::TileDir::buildNames() {
|
||||||
//if (!enabled) return;
|
//if (!enabled) return;
|
||||||
lock();
|
lock();
|
||||||
|
PIMutexLocker ml(e_mutex);
|
||||||
content.clear();
|
content.clear();
|
||||||
PIChar t;
|
PIChar t;
|
||||||
CharFlags cf = 0;
|
CharFlags cf = 0;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ private:
|
|||||||
PIVector<PIFile::FileInfo> entries;
|
PIVector<PIFile::FileInfo> entries;
|
||||||
PIDir dir;
|
PIDir dir;
|
||||||
PIMap<PIString, PIPair<int, int> > prev_pos;
|
PIMap<PIString, PIPair<int, int> > prev_pos;
|
||||||
|
mutable PIMutex e_mutex;
|
||||||
bool resized, remote, remote_mode;
|
bool resized, remote, remote_mode;
|
||||||
void * fm, * key_func;
|
void * fm, * key_func;
|
||||||
EVENT3(actionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data)
|
EVENT3(actionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data)
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ public:
|
|||||||
ret->content << TileList::Row("Local file manager", CellFormat());
|
ret->content << TileList::Row("Local file manager", CellFormat());
|
||||||
ret->content << TileList::Row("Connect to another daemon", CellFormat());
|
ret->content << TileList::Row("Connect to another daemon", CellFormat());
|
||||||
ret->content << TileList::Row("Peer info", CellFormat());
|
ret->content << TileList::Row("Peer info", CellFormat());
|
||||||
|
ret->content << TileList::Row("Peer reinit", CellFormat());
|
||||||
ret->content << TileList::Row("Exit", CellFormat());
|
ret->content << TileList::Row("Exit", CellFormat());
|
||||||
ret->selection_mode = TileList::NoSelection;
|
ret->selection_mode = TileList::NoSelection;
|
||||||
return ret;
|
return ret;
|
||||||
@@ -136,10 +137,9 @@ public:
|
|||||||
", " + PIString::fromNumber(cur_peer)
|
", " + PIString::fromNumber(cur_peer)
|
||||||
, CellFormat());
|
, CellFormat());
|
||||||
piForeachC(PIPeer::PeerInfo &p , daemon_.allPeers())
|
piForeachC(PIPeer::PeerInfo &p , daemon_.allPeers())
|
||||||
peers_tl->content << TileList::Row(p.name + " | " + PIString::fromNumber(p.dist) +
|
peers_tl->content << TileList::Row(p.name + " | d = " + PIString::fromNumber(p.dist) +
|
||||||
" | " + PIString::fromNumber(p.ping()) +
|
" | p = " + PIString::fromNumber(p.ping()) +
|
||||||
" | " + PIString::fromNumber(p.addresses.size_s()) +
|
" | n = " + PIString::fromBool(p.isNeighbour())
|
||||||
" | " + PIString::fromBool(p.isNeighbour())
|
|
||||||
, CellFormat());
|
, CellFormat());
|
||||||
PIPeer::PeerInfo pi = daemon_.selfInfo();
|
PIPeer::PeerInfo pi = daemon_.selfInfo();
|
||||||
if (cur_peer >= 0 && cur_peer < daemon_.allPeers().size_s()) pi = daemon_.allPeers()[cur_peer];
|
if (cur_peer >= 0 && cur_peer < daemon_.allPeers().size_s()) pi = daemon_.allPeers()[cur_peer];
|
||||||
@@ -147,10 +147,9 @@ public:
|
|||||||
peerinfo_tl->content << TileSimple::Row("Addreses: " + PIString::fromNumber(pi.addresses.size()), CellFormat());
|
peerinfo_tl->content << TileSimple::Row("Addreses: " + PIString::fromNumber(pi.addresses.size()), CellFormat());
|
||||||
peerinfo_tl->content << TileSimple::Row("Neighbours: " + pi.neighbours.join(", "), CellFormat());
|
peerinfo_tl->content << TileSimple::Row("Neighbours: " + pi.neighbours.join(", "), CellFormat());
|
||||||
piForeachC(PIPeer::PeerInfo::Address &a , pi.addresses)
|
piForeachC(PIPeer::PeerInfo::Address &a , pi.addresses)
|
||||||
addrs_tl->content << TileList::Row(a.address + " | " + a.netmask +
|
addrs_tl->content << TileList::Row(a.address +
|
||||||
" | " + PIString::fromNumber(a.ping) +
|
" | p = " + PIString::fromNumber(a.ping) +
|
||||||
" | " + PIString::fromNumber(a.last_ping.toSeconds()) +
|
" | a = " + PIString::fromBool(a.isAvailable()), CellFormat());
|
||||||
" | " + PIString::fromBool(a.isAvailable()), CellFormat());
|
|
||||||
typedef PIPair<PIString, PIVector <PIPeer::PeerInfo* > > PeerPair;
|
typedef PIPair<PIString, PIVector <PIPeer::PeerInfo* > > PeerPair;
|
||||||
PIStringList peermap;
|
PIStringList peermap;
|
||||||
piForeachC(PeerPair &p , daemon_._peerMap()) {
|
piForeachC(PeerPair &p , daemon_._peerMap()) {
|
||||||
@@ -182,7 +181,8 @@ public:
|
|||||||
case 1: tfm->show(); break;
|
case 1: tfm->show(); break;
|
||||||
case 2: daemon_.showMainList(); tdaemon->show(); break;
|
case 2: daemon_.showMainList(); tdaemon->show(); break;
|
||||||
case 3: tpeer->show(); peers_tl->setFocus(); break;
|
case 3: tpeer->show(); peers_tl->setFocus(); break;
|
||||||
case 4: PIKbdListener::exiting = true; break;
|
case 4: daemon_.reinit(); tmenu->show(); break;
|
||||||
|
case 5: PIKbdListener::exiting = true; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user