Exemple #1
0
int ttDiscardUnsentMessages(int networkNbr)
{
  NetworkInterface* nwi = getNetwork(networkNbr);
  if (nwi == NULL) {
    char buf[200];
    sprintf(buf, "ttDiscardUnsentMessages: Network #%d not present!", networkNbr);
    TT_MEX_ERROR(buf);
    return -1;
  }

  RTnetwork *nwsys = nwi->nwsys;
  // get own network node handle
  NWnode *sender = nwsys->nwnodes[nwi->nodeNbr];

  int nbr;
  // discard all messages from preprocQ
  nbr = deleteMessages((NWmsg *)sender->preprocQ->getFirst());

  // The wireless network does not use the inputQ in the same way as the wired.
  if ( nwsys->type == CSMACD || nwsys->type == CSMAAMP || nwsys->type == RR ||
       nwsys->type == FDMA || nwsys->type == TDMA || nwsys->type == SFDSE){
    NWmsg *msg = (NWmsg *)sender->inputQ->getFirst();
    // is the first inputQ message just being sent?
    if (nwsys->sending == nwi->nodeNbr) {
      // yes, discard all but the first
      if (msg != NULL)
	nbr += deleteMessages((NWmsg *)msg->getNext());
    }
    else
      // no, discard whole inputQ
      nbr += deleteMessages(msg);
  }
  return nbr;
}
void AccountSettings::removeAccount()
{
    QModelIndex index = accountView->currentIndex();
    if (!index.isValid())
        return;

    QMailAccount account(accountModel->idFromIndex(index));

    QString message = tr("Remove %1?").arg(account.name());
    if (QMessageBox::question( this, tr("Remove account"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
        // We could simply delete the account since QMailStore::deleteAccount
        // will remove all folders and messages, but for now we will remove the
        // messages manually so we can give progress indication (eventually, we
        // might add progress notification to QMailStore)

        // Number of messages required before we use a progress indicator
        static const int MinimumForProgressIndicator = 20;

        // Maximum messages processed per batch operation
        static const int MaxBatchSize = 50;
        static const int BatchMinimumForProgressIndicator = 2 * MaxBatchSize + 1;

        // Remove the messages and folders from this account (not just in the Inbox)
        QMailMessageKey messageKey(QMailMessageKey::parentAccountId(account.id()));
        const int count = QMailStore::instance()->countMessages(messageKey);
        if (count >= MinimumForProgressIndicator) {
            deleteMessageIds = QMailStore::instance()->queryMessages(messageKey);
            deleteProgress = 0;

            deleteBatchSize = 1;
            if (count >= BatchMinimumForProgressIndicator) {
                // Process this list in batches of roughly equivalent size
                int batchCount = (count / MaxBatchSize) + (count % MaxBatchSize ? 1 : 0);
                deleteBatchSize = ((count / batchCount) + (count % batchCount ? 1 : 0));
            }

            statusDisplay->setProgress(0, count);
            statusDisplay->setStatus(tr("Removing messages"));
        } else {
            // No progress indication is required - allow the messages to be removed in account deletion
            deleteMessageIds = QMailMessageIdList();
        }

        deleteAccountId = account.id();
        QTimer::singleShot(0, this, SLOT(deleteMessages()));
    }
}
Exemple #3
0
void CTalkMasterConsoleDlg::releaseCurrentSettings()
{
	struct _iComQueueList *list = m_pIcomQueueList;
	struct _itemData *item = m_pItemData;

	outputDebug(_T("releaseCurrentSettings: Deleting Calls Waiting Information"));

	if( m_pCallWaitingItem )							// Is one already selected?
	{
		if( m_pCallWaitingItem->hCallQueue )			// If we have an archive open
			audioArchive.Close(m_pCallWaitingItem->hCallQueue);

//		m_pCallWaitingItem->hCallQueue = NULL;			// Should we be clearing this out???

		m_pCallWaitingItem = NULL;						// No more item
	}

	clearCallsWaitingItemData();
	m_listCallsWaiting.DeleteAllItems();

	outputDebug(_T("releaseCurrentSettings: Deleting Queue Information"));

	while(list)										// Get rid of the queue information
	{
		m_pIcomQueueList = list->next;
		free(list);
		list = m_pIcomQueueList;
	}

	outputDebug(_T("releaseCurrentSettings: Deleting Intercom Information"));

	Sleep(200);										// Give everything a chance to settle down

	deleteIcoms(TRUE);								// Clear the list

	while(item)
	{
		m_pItemData = item->next;
		free(item);
		item = m_pItemData;
	}

	outputDebug(_T("releaseCurrentSettings: Deleting Server Group Information"));

	deleteGroups();
	deleteMessages();
}
void AccountSettings::deleteMessages()
{
    if (!deleteMessageIds.isEmpty()) {
        // Process the next batch
        QMailMessageIdList batch(deleteMessageIds.mid(0, deleteBatchSize));
        if (deleteMessageIds.count() > deleteBatchSize) {
            deleteMessageIds = deleteMessageIds.mid(deleteBatchSize);
        } else {
            deleteMessageIds.clear();
        }

        QMailStore::instance()->removeMessages(QMailMessageKey::id(batch), QMailStore::NoRemovalRecord);
        deleteProgress += batch.count();

        statusDisplay->setProgress(deleteProgress, deleteProgress + deleteMessageIds.count());
        QTimer::singleShot(0, this, SLOT(deleteMessages()));
    } else {
        // Remove the account now
        QMailStore::instance()->removeAccount(deleteAccountId);

        statusDisplay->setVisible(false);
    }
}
void TelegramCache::deleteMessages(const InputPeer &peer)
{
    return deleteMessages(TelegramTools::inputPeerPeer(peer));
}