示例#1
0
    // open a new TCP socket, in string format "IP:port"
    id_t 
    VASTnet::openSocket (IPaddr &ip_port, bool is_secure)
    {
        // if we're not yet initialized, deny internally
        if (isJoined () == false)
            return NET_ID_UNASSIGNED;

        // get unique ID from network layer, to represent this socket
        id_t socket_id = getUniqueID ();
        if (socket_id == NET_ID_UNASSIGNED)
            return NET_ID_UNASSIGNED;

        // make connection (and wait for response)
        Addr addr;        
        addr.publicIP = ip_port;
        addr.host_id  = socket_id;

        this->storeMapping (addr);

        // NOTE: we don't need to worry about cleanConnections () disconnect this connection, 
        //       as this socket will not have any time record
        // TODO: perhaps release socket_id if connection fails?
        if (_manager->connect (socket_id, addr.publicIP.host, addr.publicIP.port, is_secure) == false)
            return NET_ID_UNASSIGNED;
               
        return socket_id;
    }
示例#2
0
int
Thread::join(void *&retval)
{
    if (isNotOk() || !isStarted() || isDetached()) return(-1);
    if (isJoined()) return(0);
    retval = NULL;
    int status = ::pthread_join(state_.id_, &retval);
    ThreadMutexLock lock(state_.cs_);
    state_.joined_ = true;
    setOk(status == 0);
    return(status);
}
int QXmppMucRoom::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 32)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 32;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QXmppMucRoom::Actions*>(_v) = allowedActions(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isJoined(); break;
        case 2: *reinterpret_cast< QString*>(_v) = jid(); break;
        case 3: *reinterpret_cast< QString*>(_v) = name(); break;
        case 4: *reinterpret_cast< QString*>(_v) = nickName(); break;
        case 5: *reinterpret_cast< QStringList*>(_v) = participants(); break;
        case 6: *reinterpret_cast< QString*>(_v) = password(); break;
        case 7: *reinterpret_cast< QString*>(_v) = subject(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 4: setNickName(*reinterpret_cast< QString*>(_v)); break;
        case 6: setPassword(*reinterpret_cast< QString*>(_v)); break;
        case 7: setSubject(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
示例#4
0
bool Room::isOverlapped(Room* r1)
{
    if((this == r1) || (this == r1->alternate_room.get()) || (alternate_room.get() == r1))
    {
        return false;
    }

    if(bb_min[0] >= r1->bb_max[0] || bb_max[0] <= r1->bb_min[0] ||
       bb_min[1] >= r1->bb_max[1] || bb_max[1] <= r1->bb_min[1] ||
       bb_min[2] >= r1->bb_max[2] || bb_max[2] <= r1->bb_min[2])
    {
        return false;
    }

    return !isJoined(r1);
}
示例#5
0
Thread::~Thread()
{
    ThreadMutexLock lock(state_.cs_);

    if (isOk() && isStarted() && !isDetached())
    {
        void *retval = NULL;
        if (!isCanceled())
        {
            state_.canceled_ = true;
            ::pthread_cancel(state_.id_);
        }
        if (!isJoined())
        {
            state_.joined_ = true;
            ::pthread_join(state_.id_, &retval);
        }
    }
    ::pthread_attr_destroy(&state_.attr_);
    setOk(false);
}