void TransportRegistrationManager::transportRegistrationFinished()
{
	JT_Register *task = (JT_Register *)sender();
	
	if (task->success()) {
		_registered = true;
		emit registrationStatusChanged(_registered, _usernamesForTasks[task]);
		emit registrationFinished();
	}
	
	_usernamesForTasks.remove(task);
}
void RegistrationHandler::registrationStatus(
    bb::platform::bbm::RegistrationState::Type state)
{
  // Based on the state, decide whether we need to register. If we already
  // registered successfully once (i.e. on a previous application run), then
  // we will not call requestRegisterApplication() again.
  qDebug() << "Received a BBM Social Platform registration access state="
      << state;
  switch (mProgress)
  {
  case BbmRegistrationProgress::Pending:
    if (state != RegistrationState::Pending)
    {
      registrationFinished();
      return;
    }
    // Otherwise, ignore since registration is still in progress.
    break;

  case BbmRegistrationProgress::Started:
    if (mContext->isAccessAllowed())
    {
      // Access is allowed, the application is registered.
      registrationFinished();
      return;
    }
    if (mContext->registrationState() == RegistrationState::Unknown)
    {
      // Status is not yet known. Wait for an event that will deliver the
      // status.
      qDebug() << "BBM Social Platform access state is UNKNOWN; waiting "
          "for the initial status";
      return;
    }
    // Start registration.
    if (mContext->requestRegisterApplication())
    {
      // Registration started. The user will see a dialog informing them
      // that your application is connecting to BBM.
      mProgress = BbmRegistrationProgress::Pending;
      qDebug() << "BBM Social Platform registration started";
      qDebug() << "Verify you are using a valid UUID";
      return;
    }
    // Could not start registration. No dialogs were shown.
    qDebug() << "BBM Social Platform registration could not be started";
    registrationFinished();
    break;

  case BbmRegistrationProgress::Finished:
    if (mContext->isAccessAllowed() != mRegistered)
    {
      // Access to the BBM Social Platform has changed.
      registrationFinished();
    }
    break;

  default:
    qDebug() << "Ignoring BBM Social Platform access state=" << state
        << "when progress=" << mProgress;
    break;
  }
}
void MRFRegistration2DParametersWidget::startRegistration()
{
	/*
	/////////////////////////////////////////////////////////////////
	// Get the values of the parameters out of the controls
	// and then emit the signal and close the box
	//////////////////////////////////////////////////////////////////
	ParameterSet params;
	params.gridSpacing = this->spacingValue->value();
	params.labelInc = this->labelIncValue->value();
	params.labelSteps = this->labelStepsValue->value();
	params.maxDisplacement = this->maxDisplacementValue->value();
	params.optimiserIterations = this->optimiserIterationsValue->value();
	params.regularisationAmount = this->regularisationValue->value();
	params.resolutionLevels = this->multiResultionValue->value();
	params.useSparseSampling = this->useSparseSampling->isChecked();
	params.xGridOrigin = this->xOriginValue->value();
	params.xGridSize   = this->xSizeValue->value();
	params.yGridOrigin = this->yOriginValue->value();
	params.yGridSize   = this->ySizeValue->value();
	params.metricType  = this->metricValue->currentIndex();

	 */

	// do some sanity checking
	//
	//
	//
	if(this->fixedImageSelector->currentIndex() == 0)
	{
		QMessageBox box;
		box.setText(tr("No fixed Image Set"));
		box.exec();
		return;
	}

	if(this->movingImageSelector->currentIndex() == 0)
	{
		QMessageBox box;
		box.setText(tr("No moving Image Set"));
		box.exec();
		return;
	}

	if(this->movingImageSelector->currentIndex() == this->fixedImageSelector->currentIndex())
	{
		QMessageBox box;
		box.setText(tr("Fixed and Moving are the same... pretty pointless"));
		box.exec();
		return;
	}


	// create the data nodes to pass to the reg display
	//
	//
	//
	mitk::DataNode::Pointer fixedNode = mitk::DataNode::New();
	fixedNode->SetData(this->imageHolder[this->fixedImageSelector->currentIndex()-1]);
	mitk::DataNode::Pointer movingNode = mitk::DataNode::New();
	movingNode->SetData(this->imageHolder[this->movingImageSelector->currentIndex()-1]);


	MRFRegistration2DDisplayWidget * regDisplay = new MRFRegistration2DDisplayWidget(this);
	regDisplay->setFixedImage(fixedNode);
	regDisplay->setMovingImage(movingNode);

	regDisplay->setXGridOrigin(this->xOriginValue->value());
	regDisplay->setYGridOrigin(this->yOriginValue->value());
	regDisplay->setXGridSize(this->xSizeValue->value());
	regDisplay->setYGridSize(this->ySizeValue->value());
	regDisplay->setGridSpacing(this->spacingValue->value());
	regDisplay->setLabelSteps(this->labelStepsValue->value());
	regDisplay->setLabelInc(this->labelIncValue->value());
	regDisplay->setOptimiserIterations(this->optimiserIterationsValue->value());
	regDisplay->setUseSparseSampling(this->useSparseSampling->isChecked());
	regDisplay->setResolutionLevels(this->multiResultionValue->value());
	regDisplay->initialise();


	// connect the output
	connect(regDisplay, SIGNAL(registrationFinished(mitk::DataNode::Pointer)), this, SLOT(getDisplacement(mitk::DataNode::Pointer)));


	regDisplay->show();


	//emit sendData(params);


}