//
//  The contents of this file are subject to the Mozilla Public License
//  Version 1.0 (the "License"); you may not use this file except in
//  compliance with the License. You may obtain a copy of the License at
//  http://www.mozilla.org/MPL/
// 
//  Software distributed under the License is distributed on an "AS IS"
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
//  the License for the specific language governing rights and limitations
//  under the License.
// 
//  The Original Code is CPhone, a cross platform voip gui.
//
//  The Initial Developer of the Original Code is Derek Smithies.
//
//  Copyright (C) 2002 Indranet Technologies Ltd, 
//                                  http://www.indranet-technologies.com
//  All Rights Reserved.
//
//  Contributor(s): _______________


/*
 *
 *  $Log: message.cxx,v $
 *  Revision 1.2  2004/04/23 05:09:59  dereksmithies
 *  Fixes so it works with latest openh323 lib, and not lock X display.
 *
 *  Revision 1.1  2003/05/09 03:02:35  dereksmithies
 *  Add thread safe mechanism to display messages.
 *
 *
 *
 *
 *
 */

#include <qevent.h>
#include <qapplication.h>
#include <qlabel.h>

#ifdef __GNUC__
#pragma implementation "message.h"
#endif

#include "message.h"
#include "messagebox.h"

#define CUSTOM_EVENT_SETUP (QEvent::User + 1)

ThreadSafeMessage::ThreadSafeMessage(QString newTitle, QString newMessage) 
  : FormMessageBox( 0, "Message Box", FALSE, WDestructiveClose)
{
  message = newMessage;
  title  = newTitle;

  move(10, 10);

  QApplication::postEvent(this, new QCustomEvent(CUSTOM_EVENT_SETUP));

}

ThreadSafeMessage::~ThreadSafeMessage()
{
}


void ThreadSafeMessage::Setup()
{
  this->setCaption(title);

  TextLabelCondition->setText(message);  
}


void ThreadSafeMessage::AcceptConditionSlot()
{
  close(TRUE);
}  


void ThreadSafeMessage::customEvent(QCustomEvent *ce)
{
 if (ce->type()  == CUSTOM_EVENT_SETUP)
    Setup();
}


syntax highlighted by Code2HTML, v. 0.9.1