Esempio n. 1
0
void BuddyLabel::mouseReleaseEvent(QMouseEvent *)
{
    if (buddy() && buddy()->isEnabled()) {
        #ifndef ENABLE_KDE_SUPPORT
        PathRequester *pr=qobject_cast<PathRequester*>(buddy());
        if (pr) {
            pr->setFocus();
            return;
        }
        #endif

        buddy()->setFocus();

        QCheckBox *cb=qobject_cast<QCheckBox*>(buddy());
        if (cb) {
            cb->setChecked(!cb->isChecked());
            return;
        }
        QRadioButton *rb=qobject_cast<QRadioButton*>(buddy());
        if (rb) {
            rb->setChecked(!rb->isChecked());
            return;
        }
        QComboBox *combo=qobject_cast<QComboBox*>(buddy());
        if (combo) {
            combo->showPopup();
            return;
        }
    }
}
Esempio n. 2
0
void BuddyList::loadFromStream_(std::istream& stream)
{
  std::string line;
  while (std::getline(stream, line))
  {
    std::string hostname = line.substr(0,16);
    std::string nick = line.substr(17);
    Buddy buddy(nick, hostname);
    buddies_.push_back(buddy);
  }
}
Esempio n. 3
0
void SoundBuddyConfigurationWidget::updateState()
{
	m_customSoundSelectFile->setEnabled(m_useCustomSoundCheckBox->isChecked());

	if (buddy().property("sound:use_custom_sound", false).toBool() != m_useCustomSoundCheckBox->isChecked())
	{
		m_stateNotifier->setState(StateChangedDataValid);
		return;
	}

	if (!m_useCustomSoundCheckBox->isChecked())
	{
		m_stateNotifier->setState(StateNotChanged);
		return;
	}

	if (buddy().property("sound:custom_sound", QString{}).toString() != m_customSoundSelectFile->file())
		m_stateNotifier->setState(StateChangedDataValid);
	else
		m_stateNotifier->setState(StateNotChanged);
}
Esempio n. 4
0
 static void Reclaim(FreeList &pav,Space &p)
 { // 伙伴系统的回收算法 将p所指的释放块回收到可利用空间表pav中
   Space s;
   s=buddy(p); // 伙伴块的起始地址
   while(s>=r&&s<r+pav[m].nodesize&&s->tag==0) // 归并伙伴块,伙伴块起始地址在有效范围内且伙伴块空闲
   { // 从链表上删除该结点
     if(s->llink==s&&s->rlink==s) // 链表上仅此一个结点
       pav[s->kval].first=NULL; // 置此链表为空
     else // 链表上不止一个结点
     {
       s->llink->rlink=s->rlink; // 前驱的后继为该结点的后继
       s->rlink->llink=s->llink; // 后继的前驱为该结点的前驱
       if(pav[s->kval].first==s) // s是链表的第一个结点
         pav[s->kval].first=s->rlink; // 表头指向下一个结点
     } // 以下修改结点头部
     if((p-r)%int(pow(2,p->kval+1))==0) // p为前块
       p->kval++;
     else // p为后块
     {
       s->kval=p->kval+1;
       p=s; // p指向新块首地址
     }
     s=buddy(p); // 下一个伙伴块的起始地址
   }
   // 以下将p插到可利用空间表中
   p->tag=0;
   if(pav[p->kval].first==NULL) // 该链表空
     pav[p->kval].first=p->llink=p->rlink=p;
   else // 插在表头
   {
     p->rlink=pav[p->kval].first;
     p->llink=p->rlink->llink;
     p->rlink->llink=p;
     p->llink->rlink=p;
     pav[p->kval].first=p;
   }
   p=NULL;
 }
Esempio n. 5
0
void PurpleChatMngr::ChatAddUsersCbk(PurpleConversation *conv, GList *users, gboolean new_arrivals)
{
	GList *l;
	PurpleAccount	*gAccount	 = purple_conversation_get_account(conv);
	const char		*gPrclId	 = purple_account_get_protocol_id(gAccount);
	IMAccount		*account	 = _accountMngr->FindIMAccount(purple_account_get_username(gAccount), PurpleIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t		*mConv		 = NULL;
	IMChatSession	*chatSession = NULL;
	PurpleIMChat	*mChat		 = FindIMChat(*account);

	if (!mChat)
		LOG_FATAL("Can't find IMChat !");

	mConv       = (mConvInfo_t *)   conv->ui_data;
	chatSession = mConv->conv_session;	//VOXOX - JRT - 2009.07.09 

	for (l = users; l != NULL; l = l->next)
	{
		PurpleConvChatBuddy *gCCBuddy = (PurpleConvChatBuddy *) l->data;

		if (gCCBuddy && strcmp(purple_account_get_username(gAccount), (char *) gCCBuddy->name))
		{
			std::string buddy((char *) gCCBuddy->name);
			IMContact imContact(*account, buddy);

			if (chatSession->getIMContactSet().find(imContact) != chatSession->getIMContactSet().end())
			{
				LOG_DEBUG("IMContact for " + imContact.getContactId() + " already in IMContactSet");
			}
			else
			{
				((IMContactSet &) chatSession->getIMContactSet()).insert(imContact);

				if (chatSession->getIMContactSet().size() == 1)
				{
					//Create session when first contact is added.
					mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession);
				}

				LOG_DEBUG("IMContact " + imContact.getContactId() + " added to IMContactSet");
			}
			mChat->contactAddedEvent(*mChat, *chatSession, imContact);
		}
	}
}
Esempio n. 6
0
void BuddyEditor::setBackground(QWidget *background)
{
    clear();
    ConnectionEdit::setBackground(background);

    const LabelList label_list = background->findChildren<QLabel*>();
    foreach (QLabel *label, label_list) {
        const QString buddy_name = buddy(label, m_formWindow->core());
        if (buddy_name.isEmpty())
            continue;
        QWidget *target = background->findChild<QWidget*>(buddy_name);
        if (target == 0)
            continue;

        Connection *con = new Connection(this);
        con->setEndPoint(EndPoint::Source, label, widgetRect(label).center());
        con->setEndPoint(EndPoint::Target, target, widgetRect(target).center());
        addConnection(con);
    }
}
Esempio n. 7
0
void PurpleChatMngr::ChatRemoveUsersCbk(PurpleConversation *conv, GList *users)
{
	GList *l;
	PurpleAccount *gAccount = purple_conversation_get_account(conv);
	const char *gPrclId = purple_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(purple_account_get_username(gAccount), PurpleIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t *mConv = NULL;
	IMChatSession *chatSession = NULL;
	PurpleIMChat *mChat = FindIMChat(*account);

	if (!mChat)
		LOG_FATAL("Can't find IMChat !");

	mConv		= (mConvInfo_t *) conv->ui_data;
	chatSession = mConv->conv_session;		//VOXOX - JRT - 2009.07.09 

	for (l = users; l != NULL; l = l->next)
	{
		if (strcmp(purple_account_get_username(gAccount), (char *) l->data))
		{
			std::string buddy((char *) l->data);
			IMContact imContact(*account, buddy);

			IMContact* imContact2 = chatSession->getIMContactSet().findBy( account->getKey(), buddy );

//			if (chatSession->getIMContactSet().find(imContact) == chatSession->getIMContactSet().end())
			if ( imContact2 == NULL )
			{
				LOG_ERROR("IMContact for " + imContact.getContactId() + " not in IMContactSet");
			}
			else
			{
				LOG_DEBUG("IMContact " + imContact.getContactId() + " removed from IMContactSet");
				mChat->contactRemovedEvent(*mChat, *chatSession, buddy);
			}
		}
	}
}
Esempio n. 8
0
QVariant CommentsModel::data(const QModelIndex &index, int role) const
{
    int row = index.row();

    auto comment = m_comments.at(row);
    auto roster = m_contact.data()->client()->roster();
    switch (role) {
    case IdRole:
        return comment.value("cid");
        break;
    case FromRole: {
        int source = comment.value("uid").toInt();
        return qVariantFromValue(roster->buddy(source));
    }
    case DateRole:
        return QDateTime::fromTime_t(comment.value("date").toUInt());
    case BodyRole:
        return comment.value("text");
    default:
        break;
    }
    return QVariant::Invalid;
}
Esempio n. 9
0
void GaimChatMngr::ChatRemoveUsersCbk(GaimConversation *conv, GList *users)
{
	GList *l;
	GaimAccount *gAccount = gaim_conversation_get_account(conv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
								GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t *mConv = NULL;
	IMChatSession *chatSession = NULL;
	GaimIMChat *mChat = FindIMChat(*account);

	if (!mChat)
		LOG_FATAL("Can't find IMChat !");

	mConv = (mConvInfo_t *) conv->ui_data;
	chatSession = (IMChatSession *) mConv->conv_session;

	for (l = users; l != NULL; l = l->next)
	{
		if (strcmp(gaim_account_get_username(gAccount), (char *) l->data))
		{
			std::string buddy((char *) l->data);
			IMContact imContact(*account, buddy);

			if (chatSession->getIMContactSet().find(imContact) == chatSession->getIMContactSet().end())
			{
				LOG_ERROR("IMContact for " + imContact.getContactId() + " not in IMContactSet");
			}
			else
			{
				LOG_DEBUG("IMContact " + imContact.getContactId() + " removed from IMContactSet");
				mChat->contactRemovedEvent(*mChat, *chatSession, buddy);
			}
		}
	}
}
Esempio n. 10
0
void BuddyEditor::updateBackground()
{
    if (m_updating || background() == 0)
        return;
    ConnectionEdit::updateBackground();

    m_updating = true;
    QList<Connection *> newList;
    const LabelList label_list = background()->findChildren<QLabel*>();
    foreach (QLabel *label, label_list) {
        const QString buddy_name = buddy(label, m_formWindow->core());
        if (buddy_name.isEmpty())
            continue;

        const QList<QWidget *> targets = background()->findChildren<QWidget*>(buddy_name);
        if (targets.isEmpty())
            continue;

        QWidget *target = 0;

        QListIterator<QWidget *> it(targets);
        while (it.hasNext()) {
            QWidget *widget = it.next();
            if (widget && !widget->isHidden()) {
                target = widget;
                break;
            }
        }

        if (target == 0)
            continue;

        Connection *con = new Connection(this);
        con->setEndPoint(EndPoint::Source, label, widgetRect(label).center());
        con->setEndPoint(EndPoint::Target, target, widgetRect(target).center());
        newList.append(con);
    }

    QList<Connection *> toRemove;

    const int c = connectionCount();
    for (int i = 0; i < c; i++) {
        Connection *con = connection(i);
        QObject *source = con->object(EndPoint::Source);
        QObject *target = con->object(EndPoint::Target);
        bool found = false;
        QListIterator<Connection *> it(newList);
        while (it.hasNext()) {
            Connection *newConn = it.next();
            if (newConn->object(EndPoint::Source) == source && newConn->object(EndPoint::Target) == target) {
                found = true;
                break;
            }
        }
        if (found == false)
            toRemove.append(con);
    }
    if (!toRemove.isEmpty()) {
        DeleteConnectionsCommand command(this, toRemove);
        command.redo();
        foreach (Connection *con, toRemove)
            delete takeConnection(con);
    }

    QListIterator<Connection *> it(newList);
    while (it.hasNext()) {
        Connection *newConn = it.next();

        bool found = false;
        const int c = connectionCount();
        for (int i = 0; i < c; i++) {
            Connection *con = connection(i);
            if (con->object(EndPoint::Source) == newConn->object(EndPoint::Source) &&
                            con->object(EndPoint::Target) == newConn->object(EndPoint::Target)) {
                found = true;
                break;
            }
        }
        if (found == false) {
            AddConnectionCommand command(this, newConn);
            command.redo();
        } else {
            delete newConn;
        }
    }
    m_updating = false;
}
Esempio n. 11
0
void SoundBuddyConfigurationWidget::loadValues()
{
	m_useCustomSoundCheckBox->setChecked(buddy().property("sound:use_custom_sound", false).toBool());
	m_customSoundSelectFile->setFile(buddy().property("sound:custom_sound", QString{}).toString());
}
Esempio n. 12
0
void SoundBuddyConfigurationWidget::apply()
{
	buddy().addProperty("sound:use_custom_sound", m_useCustomSoundCheckBox->isChecked(), CustomProperties::Storable);
	buddy().addProperty("sound:custom_sound", m_customSoundSelectFile->file(), CustomProperties::Storable);
	updateState();
}
Esempio n. 13
0
void CocosEventHandler::onFriendStaged(QString s)
{
    emit buddy(s);
}
Esempio n. 14
0
QModelIndex DhQDirModel::Dvhbuddy(const QModelIndex& x1) const {
  return buddy(x1);
}
Esempio n. 15
0
/*
 * mm_malloc - Allocate a block by incrementing the brk pointer.
 *     Always allocate a block whose size is a multiple of the alignment.
 */
void *mm_malloc(size_t size) {
	int* ans = 0;
	if (size <= 0)
		return NULL;
	size_t asize = switchSize(size);
	//Check the little block cache.
	if (asize == SIZE0) {
		switch (flag1 | flag2) {
		case 0:
			flag1 = 1;
			return flagB;
		case 1:
			flag2 = 2;
			return ((int*) flagB + 4);
		case 2:
			flag1 = 1;
			return flagB;
		}
	}
	void *bp = (int*) heap_st + sizeLocation;
	//If there is no appropriate free block, increase the heap size.
	if (find(sizeLocation) == 0) {
		int overhead, overhead2;
		//If the block size is small,the header size is 8 bytes, otherwise it's 16 bytes.
		//Because 16 bytes can be seperated by 2 smaller ones.
		if (asize <= SIZE7) {
			overhead = 8;
			overhead2 = 1;
		} else {
			overhead = 16;
			overhead2 = 3;
		}
		if ((ans = mem_sbrk(asize + overhead)) == NULL)
			return NULL;
		heap_ed = (char*) heap_ed + asize + overhead;
		ans = (int*) ans + overhead2;
		PUT(ans,PACK(asize,1));
		ans = (int*) ans + 1;
	} else {
		//The part which combinate 2 smaller free blocks.
		if (freePlace == sizeLocation - 1) {
			ans = (int*) GET((int*)bp-1);
			PUT((int*)bp-1,GET(HDRP(ans)));
			int *ans2 = (int*) GET((int*)bp-1);
			PUT((int*)bp-1,GET(HDRP(ans2)));
			if (ans > ans2)
				ans = ans2;
			if (!flag)
				ans = ans + 2;
			PUT(HDRP(ans),PACK(asize,1));
		}//Get the corresponding free block.
		else if (freePlace == sizeLocation) {
			ans = (int*) GET(bp);
			PUT(bp,GET(HDRP(ans)));
			//If the current free block has been seperated.
			if (GET_IF_LOW(ans) == 1)
				PUT(HDRP(ans),PACK(asize,3));
			else
				PUT(HDRP(ans),PACK(asize,1));
		}//Seperate a larger one.
		else if (freePlace == sizeLocation + 1) {
			ans = (int*) GET((int*)bp+1);
			PUT((int*)bp+1,GET(HDRP(ans)));
			int *ans2 = (int*) (ans) + buddy(sizeLocation + 1) / 4 - 2;
			ans = ans - 2;
			//Indicate this block has been seperated.
			PUT(HDRP(ans),PACK(asize,3));
			PUT(HDRP(ans2),GET(bp));
			PUT(ans2,0x1);
			PUT(bp,(size_t)ans2);
		}
	}
	return ans;
}
Esempio n. 16
0
QModelIndex DhQAbstractTableModel::Dvhbuddy(const QModelIndex& x1) const {
  return buddy(x1);
}