00001 /* 00002 * Copyright (c) 2005 MyARM GbR, Germany 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or 00006 * without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 1. Redistributions of source code must retain the above 00009 * copyright notice, this list of conditions and the 00010 * following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above 00012 * copyright notice, this list of conditions and the 00013 * following disclaimer in the documentation and/or other 00014 * materials provided with the distribution. 00015 * 3. All advertising materials mentioning features or use of 00016 * this software must display the following acknowledgement: 00017 * This product includes software developed by 00018 * MyARM GbR and its contributors. 00019 * 4. Neither the name of MyARM GbR nor the names of its 00020 * contributors may be used to endorse or promote products 00021 * derived from this software without specific prior written 00022 * permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY MYARM GBR. AND CONTRIBUTORS 00025 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 00026 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00027 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00028 * SHALL MYARM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00029 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00031 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00032 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00033 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00034 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00035 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00036 * OF SUCH DAMAGE. 00037 */ 00038 00039 #include <QArmApplication> 00040 #include <QArmAppDefinition> 00041 00042 #include "arm4sdk.h" 00043 00044 #include "myarmsdk.h" 00045 #include "myarmsdk_dynload.h" 00046 00052 /*---------------------------------------------------------------------------*/ 00053 00054 QArmApplication::QArmApplication(const QArmAppDefinition &_appdef) 00055 :QArmInstance(_appdef){ 00056 } 00057 00058 /*---------------------------------------------------------------------------*/ 00059 00060 QArmApplication::~QArmApplication() { 00061 // only stop in case it is active 00062 if(m_active) 00063 stop(); 00064 } 00065 00066 /*---------------------------------------------------------------------------*/ 00067 00068 void QArmApplication::start(QStringList * _context_values) { 00069 00070 if(!m_active) { 00071 armsdk_subbuffer_app_context_t sdk_sb_app_context; 00072 armsdk_buffer4_t buf4; 00073 int num_sb = 0; 00074 00075 bool context = (_context_values != 0) && (_context_values->count() > 0); 00076 m_active = true; 00077 00078 // CONTEXT VALUES: 00079 // Undefined behaviour in case values and names/bindings do not match 00080 if(context) { 00081 // Initialize the context values buffer 00082 armsdk_app_context_initialize(&sdk_sb_app_context); 00083 QStringListIterator it(*_context_values); 00084 int i = 0; 00085 while(it.hasNext()) { 00086 armsdk_app_context_set(&sdk_sb_app_context, 00087 i, 00088 it.next().toAscii().constData()); 00089 ++i; 00090 }// end while 00091 00092 num_sb = addSubbuffer(num_sb, buf4, ARM_SDKSB(sdk_sb_app_context)); 00093 }// end if 00094 arm_start_application(m_id, 00095 NULL, 00096 NULL, 00097 ARM_FLAG_NONE, 00098 num_sb > 0 ? &buf4.header : ARM_BUF4_NONE, 00099 &m_appHandle); 00100 } // end if active 00101 } 00102 00103 /*--------------------------------------------------------------------------*/ 00104 00105 void QArmApplication::stop() { 00106 if(m_active) { 00107 arm_stop_application(m_appHandle, ARM_FLAG_NONE, ARM_BUF4_NONE); 00108 arm_destroy_application(m_id, ARM_FLAG_NONE, ARM_BUF4_NONE); 00109 m_active = false; 00110 } 00111 else { 00112 //qDebug("Call start() before stop()!"); 00113 } 00114 }
1.4.2