<commit_before>#include "normalvirtualkeyboardscene.h"
#include "virtualkeyitem.h"

NormalVirtualKeyboardScene::NormalVirtualKeyboardScene(QObject *parent) : VirtualKeyboardScene(parent)
{
	construct();
}

void NormalVirtualKeyboardScene::construct()
{
	const int unitWidth = 100;
	const int unitHeight = 130;
	int i = 0;
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_END, "stop", "stop", "stop", "stop", "stop", "stop", "stop"));
		list.push_back(createVirtualKeyItem(KVC_PAGEDOWN, "mode", "mode", "mode", "mode", "mode", "mode", "mode"));
		list.push_back(createVirtualKeyItem(KVC_F1, "function01", "function06", "function01", "function01", "function06", "function01", "function06"));
		list.push_back(createVirtualKeyItem(KVC_F2, "function02", "function07", "function02", "function02", "function07", "function02", "function07"));
		list.push_back(createVirtualKeyItem(KVC_F3, "function03", "function08", "function03", "function03", "function08", "function03", "function08"));
		list.push_back(createVirtualKeyItem(KVC_F4, "function04", "function09", "function04", "function04", "function09", "function04", "function09"));
		list.push_back(createVirtualKeyItem(KVC_F5, "function05", "function10", "function05", "function05", "function10", "function05", "function10"));
		list.push_back(createVirtualKeyItem(KVC_HOME, "home", "home", "home", "home", "home", "home", "home"));
		list.push_back(createVirtualKeyItem(KVC_PAGEUP, "page", "page", "page", "page", "page", "page", "page"));
		list.push_back(createVirtualKeyItem(KVC_DELETE, "del", "del", "del", "del", "del", "del", "del"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_ESC, "escape", "escape", "escape", "escape", "escape", "escape", "escape"));
		list.push_back(createVirtualKeyItem(KVC_1, "0x31", "0x21", "0x07", "0xe7", "blank", "0xc7", "blank"));
		list.push_back(createVirtualKeyItem(KVC_2, "0x32", "0x22", "0x01", "0xec", "blank", "0xcc", "blank"));
		list.push_back(createVirtualKeyItem(KVC_3, "0x33", "0x23", "0x02", "0x91", "0x87", "0xb1", "0xa7"));
		list.push_back(createVirtualKeyItem(KVC_4, "0x34", "0x24", "0x03", "0x93", "0x89", "0xb3", "0xa9"));
		list.push_back(createVirtualKeyItem(KVC_5, "0x35", "0x25", "0x04", "0x94", "0x8a", "0xb4", "0xaa"));
		list.push_back(createVirtualKeyItem(KVC_6, "0x36", "0x26", "0x05", "0x95", "0x8b", "0xb5", "0xab"));
		list.push_back(createVirtualKeyItem(KVC_7, "0x37", "0x27", "0x06", "0xf4", "0x8c", "0xd4", "0xac"));
		list.push_back(createVirtualKeyItem(KVC_8, "0x38", "0x28", "0x0d", "0xf5", "0x8d", "0xd5", "0xad"));
		list.push_back(createVirtualKeyItem(KVC_9, "0x39", "0x29", "0x0e", "0xf6", "0x8e", "0xd6", "0xae"));
		list.push_back(createVirtualKeyItem(KVC_0, "0x30", "blank", "0x0f", "0xfc", "0x86", "0xdc", "0xa6"));
		list.push_back(createVirtualKeyItem(KVC_MINUS, "0x2d", "0x3d", "0x17", "0xee", "blank", "0xce", "blank"));
		list.push_back(createVirtualKeyItem(KVC_CARET, "0x5e", "blank", "blank", "0xed", "blank", "0xcd", "blank"));
		list.push_back(createVirtualKeyItem(KVC_YEN, "0x5c", "blank", "0x09", "0xb0", "blank", "0xb0", "blank"));
		list.push_back(createVirtualKeyItem(KVC_INSERT, "ins", "ins", "ins", "ins", "ins", "ins", "ins"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_TAB, "tab", "tab", "tab", "tab", "tab", "tab", "tab"));
		list.push_back(createVirtualKeyItem(KVC_Q, "0x71", "0x51", "blank", "0xe0", "blank", "0xc0", "blank"));
		list.push_back(createVirtualKeyItem(KVC_W, "0x77", "0x57", "blank", "0xe3", "blank", "0xc3", "blank"));
		list.push_back(createVirtualKeyItem(KVC_E, "0x65", "0x45", "0x18", "0x92", "0x88", "0xb2", "0xa8"));
		list.push_back(createVirtualKeyItem(KVC_R, "0x72", "0x52", "0x12", "0x9d", "blank", "0xbd", "blank"));
		list.push_back(createVirtualKeyItem(KVC_T, "0x74", "0x54", "0x19", "0x96", "blank", "0xb6", "blank"));
		list.push_back(createVirtualKeyItem(KVC_Y, "0x79", "0x59", "0x08", "0xfd", "blank", "0xdd", "blank"));
		list.push_back(createVirtualKeyItem(KVC_U, "0x75", "0x55", "blank", "0xe5", "blank", "0xc5", "blank"));
		list.push_back(createVirtualKeyItem(KVC_I, "0x69", "0x49", "0x16", "0xe6", "blank", "0xc6", "blank"));
		list.push_back(createVirtualKeyItem(KVC_O, "0x6f", "0x4f", "blank", "0xf7", "blank", "0xd7", "blank"));
		list.push_back(createVirtualKeyItem(KVC_P, "0x70", "0x50", "0x10", "0x9e", "blank", "0xbe", "blank"));
		list.push_back(createVirtualKeyItem(KVC_AT, "0x40", "blank", "blank", "0xde", "blank", "0xde", "blank"));
		list.push_back(createVirtualKeyItem(KVC_LBRACKET, "0x5b", "blank", "0x84", "0xdf", "0xa2", "0xdf", "0xa2"));
		list.push_back(createVirtualKeyItem(KVC_RBRACKET, "0x5d", "blank", "0x85", "0xf1", "0xa3", "0xd1", "0xa3"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_LCTRL, "ctrl", "ctrl", "ctrl", "ctrl", "ctrl", "ctrl", "ctrl", true));
		list.push_back(createVirtualKeyItem(KVC_A, "0x61", "0x41", "blank", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_S, "0x73", "0x53", "0x0c", "0xe4", "blank", "0xc4", "blank"));
		list.push_back(createVirtualKeyItem(KVC_D, "0x64", "0x44", "0x14", "0x9c", "blank", "0xbc", "blank"));
		list.push_back(createVirtualKeyItem(KVC_F, "0x66", "0x46", "0x15", "0xea", "blank", "0xca", "blank"));
		list.push_back(createVirtualKeyItem(KVC_G, "0x67", "0x47", "0x13", "0x97", "blank", "0xb7", "blank"));
		list.push_back(createVirtualKeyItem(KVC_H, "0x68", "0x48", "0x0a", "0x98", "blank", "0xb8", "blank"));
		list.push_back(createVirtualKeyItem(KVC_J, "0x6a", "0x4a", "blank", "0xef", "blank", "0xcf", "blank"));
		list.push_back(createVirtualKeyItem(KVC_K, "0x6b", "0x4b", "blank", "0xe9", "blank", "0xc9", "blank"));
		list.push_back(createVirtualKeyItem(KVC_L, "0x6c", "0x4c", "0x1e", "0xf8", "blank", "0xd8", "blank"));
		list.push_back(createVirtualKeyItem(KVC_SEMICOLON, "0x3b", "0x2b", "0x82", "0xfa", "blank", "0xda", "blank"));
		list.push_back(createVirtualKeyItem(KVC_COLON, "0x3a", "0x2a", "0x81", "0x99", "blank", "0xb9", "blank"));
		list.push_back(createVirtualKeyItem(KVC_UNDERSCORE, "blank", "0x5f", "0x83", "0xfb", "blank", "0xdb", "blank"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_LSHIFT, "shift_l", "shift_l", "shift_l", "shift_l", "shift_l", "shift_l", "shift_l", true));
		list.push_back(createVirtualKeyItem(KVC_Z, "0x7a", "0x5a", "blank", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_X, "0x78", "0x58", "0x1c", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_C, "0x63", "0x43", "0x1a", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_V, "0x76", "0x56", "0x11", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_B, "0x62", "0x42", "0x1b", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_N, "0x6e", "0x4e", "blank", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_M, "0x6d", "0x4d", "0x0b", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_COMMA, "0x2c", "0x3c", "0x1f", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_PERIOD, "0x2e", "0x3e", "0x1d", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_SLASH, "0x2f", "0x3f", "0x80", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_RSHIFT, "shift_r", "shift_r", "shift_r", "shift_r", "shift_r", "shift_r", "shift_r", true));
		list.push_back(createVirtualKeyItem(KVC_UP, "up", "up", "up", "up", "up", "up", "up"));
		list.push_back(createVirtualKeyItem(KVC_HIRAGANA, "kana", "kana", "kana", "kana", "kana", "kana", "kana"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_CAPSLOCK, "caps", "caps", "caps", "caps", "caps", "caps", "caps"));
		list.push_back(createVirtualKeyItem(KVC_LALT, "grph", "grph", "grph", "grph", "grph", "grph", "grph", true));
		list.push_back(createVirtualKeyItem(KVC_SPACE, "space", "space", "space", "space", "space", "space", "space"));
		list.push_back(createVirtualKeyItem(KVC_LEFT, "left", "left", "left", "left", "left", "left", "left"));
		list.push_back(createVirtualKeyItem(KVC_DOWN, "down", "down", "down", "down", "down", "down", "down"));
		list.push_back(createVirtualKeyItem(KVC_RIGHT, "right", "right", "right", "right", "right", "right", "right"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}

	auto returnKey = createVirtualKeyItem(KVC_ENTER, "return", "return", "return", "return", "return", "return", "return");
	returnKey->setPos(unitWidth * 13.75, unitHeight * 2);

	setSceneRect(itemsBoundingRect());

}
<commit_msg>かなキーの定義漏れを修正<commit_after>#include "normalvirtualkeyboardscene.h"
#include "virtualkeyitem.h"

NormalVirtualKeyboardScene::NormalVirtualKeyboardScene(QObject *parent) : VirtualKeyboardScene(parent)
{
	construct();
}

void NormalVirtualKeyboardScene::construct()
{
	const int unitWidth = 100;
	const int unitHeight = 130;
	int i = 0;
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_END, "stop", "stop", "stop", "stop", "stop", "stop", "stop"));
		list.push_back(createVirtualKeyItem(KVC_PAGEDOWN, "mode", "mode", "mode", "mode", "mode", "mode", "mode"));
		list.push_back(createVirtualKeyItem(KVC_F1, "function01", "function06", "function01", "function01", "function06", "function01", "function06"));
		list.push_back(createVirtualKeyItem(KVC_F2, "function02", "function07", "function02", "function02", "function07", "function02", "function07"));
		list.push_back(createVirtualKeyItem(KVC_F3, "function03", "function08", "function03", "function03", "function08", "function03", "function08"));
		list.push_back(createVirtualKeyItem(KVC_F4, "function04", "function09", "function04", "function04", "function09", "function04", "function09"));
		list.push_back(createVirtualKeyItem(KVC_F5, "function05", "function10", "function05", "function05", "function10", "function05", "function10"));
		list.push_back(createVirtualKeyItem(KVC_HOME, "home", "home", "home", "home", "home", "home", "home"));
		list.push_back(createVirtualKeyItem(KVC_PAGEUP, "page", "page", "page", "page", "page", "page", "page"));
		list.push_back(createVirtualKeyItem(KVC_DELETE, "del", "del", "del", "del", "del", "del", "del"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_ESC, "escape", "escape", "escape", "escape", "escape", "escape", "escape"));
		list.push_back(createVirtualKeyItem(KVC_1, "0x31", "0x21", "0x07", "0xe7", "blank", "0xc7", "blank"));
		list.push_back(createVirtualKeyItem(KVC_2, "0x32", "0x22", "0x01", "0xec", "blank", "0xcc", "blank"));
		list.push_back(createVirtualKeyItem(KVC_3, "0x33", "0x23", "0x02", "0x91", "0x87", "0xb1", "0xa7"));
		list.push_back(createVirtualKeyItem(KVC_4, "0x34", "0x24", "0x03", "0x93", "0x89", "0xb3", "0xa9"));
		list.push_back(createVirtualKeyItem(KVC_5, "0x35", "0x25", "0x04", "0x94", "0x8a", "0xb4", "0xaa"));
		list.push_back(createVirtualKeyItem(KVC_6, "0x36", "0x26", "0x05", "0x95", "0x8b", "0xb5", "0xab"));
		list.push_back(createVirtualKeyItem(KVC_7, "0x37", "0x27", "0x06", "0xf4", "0x8c", "0xd4", "0xac"));
		list.push_back(createVirtualKeyItem(KVC_8, "0x38", "0x28", "0x0d", "0xf5", "0x8d", "0xd5", "0xad"));
		list.push_back(createVirtualKeyItem(KVC_9, "0x39", "0x29", "0x0e", "0xf6", "0x8e", "0xd6", "0xae"));
		list.push_back(createVirtualKeyItem(KVC_0, "0x30", "blank", "0x0f", "0xfc", "0x86", "0xdc", "0xa6"));
		list.push_back(createVirtualKeyItem(KVC_MINUS, "0x2d", "0x3d", "0x17", "0xee", "blank", "0xce", "blank"));
		list.push_back(createVirtualKeyItem(KVC_CARET, "0x5e", "blank", "blank", "0xed", "blank", "0xcd", "blank"));
		list.push_back(createVirtualKeyItem(KVC_YEN, "0x5c", "blank", "0x09", "0xb0", "blank", "0xb0", "blank"));
		list.push_back(createVirtualKeyItem(KVC_INSERT, "ins", "ins", "ins", "ins", "ins", "ins", "ins"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_TAB, "tab", "tab", "tab", "tab", "tab", "tab", "tab"));
		list.push_back(createVirtualKeyItem(KVC_Q, "0x71", "0x51", "blank", "0xe0", "blank", "0xc0", "blank"));
		list.push_back(createVirtualKeyItem(KVC_W, "0x77", "0x57", "blank", "0xe3", "blank", "0xc3", "blank"));
		list.push_back(createVirtualKeyItem(KVC_E, "0x65", "0x45", "0x18", "0x92", "0x88", "0xb2", "0xa8"));
		list.push_back(createVirtualKeyItem(KVC_R, "0x72", "0x52", "0x12", "0x9d", "blank", "0xbd", "blank"));
		list.push_back(createVirtualKeyItem(KVC_T, "0x74", "0x54", "0x19", "0x96", "blank", "0xb6", "blank"));
		list.push_back(createVirtualKeyItem(KVC_Y, "0x79", "0x59", "0x08", "0xfd", "blank", "0xdd", "blank"));
		list.push_back(createVirtualKeyItem(KVC_U, "0x75", "0x55", "blank", "0xe5", "blank", "0xc5", "blank"));
		list.push_back(createVirtualKeyItem(KVC_I, "0x69", "0x49", "0x16", "0xe6", "blank", "0xc6", "blank"));
		list.push_back(createVirtualKeyItem(KVC_O, "0x6f", "0x4f", "blank", "0xf7", "blank", "0xd7", "blank"));
		list.push_back(createVirtualKeyItem(KVC_P, "0x70", "0x50", "0x10", "0x9e", "blank", "0xbe", "blank"));
		list.push_back(createVirtualKeyItem(KVC_AT, "0x40", "blank", "blank", "0xde", "blank", "0xde", "blank"));
		list.push_back(createVirtualKeyItem(KVC_LBRACKET, "0x5b", "blank", "0x84", "0xdf", "0xa2", "0xdf", "0xa2"));
		list.push_back(createVirtualKeyItem(KVC_RBRACKET, "0x5d", "blank", "0x85", "0xf1", "0xa3", "0xd1", "0xa3"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_LCTRL, "ctrl", "ctrl", "ctrl", "ctrl", "ctrl", "ctrl", "ctrl", true));
		list.push_back(createVirtualKeyItem(KVC_A, "0x61", "0x41", "blank", "0xe1", "blank", "0xc1", "blank"));
		list.push_back(createVirtualKeyItem(KVC_S, "0x73", "0x53", "0x0c", "0xe4", "blank", "0xc4", "blank"));
		list.push_back(createVirtualKeyItem(KVC_D, "0x64", "0x44", "0x14", "0x9c", "blank", "0xbc", "blank"));
		list.push_back(createVirtualKeyItem(KVC_F, "0x66", "0x46", "0x15", "0xea", "blank", "0xca", "blank"));
		list.push_back(createVirtualKeyItem(KVC_G, "0x67", "0x47", "0x13", "0x97", "blank", "0xb7", "blank"));
		list.push_back(createVirtualKeyItem(KVC_H, "0x68", "0x48", "0x0a", "0x98", "blank", "0xb8", "blank"));
		list.push_back(createVirtualKeyItem(KVC_J, "0x6a", "0x4a", "blank", "0xef", "blank", "0xcf", "blank"));
		list.push_back(createVirtualKeyItem(KVC_K, "0x6b", "0x4b", "blank", "0xe9", "blank", "0xc9", "blank"));
		list.push_back(createVirtualKeyItem(KVC_L, "0x6c", "0x4c", "0x1e", "0xf8", "blank", "0xd8", "blank"));
		list.push_back(createVirtualKeyItem(KVC_SEMICOLON, "0x3b", "0x2b", "0x82", "0xfa", "blank", "0xda", "blank"));
		list.push_back(createVirtualKeyItem(KVC_COLON, "0x3a", "0x2a", "0x81", "0x99", "blank", "0xb9", "blank"));
		list.push_back(createVirtualKeyItem(KVC_UNDERSCORE, "blank", "0x5f", "0x83", "0xfb", "blank", "0xdb", "blank"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_LSHIFT, "shift_l", "shift_l", "shift_l", "shift_l", "shift_l", "shift_l", "shift_l", true));
		list.push_back(createVirtualKeyItem(KVC_Z, "0x7a", "0x5a", "blank", "0xe2", "0x8f", "0xc2", "0xaf"));
		list.push_back(createVirtualKeyItem(KVC_X, "0x78", "0x58", "0x1c", "0x9b", "blank", "0xbb", "blank"));
		list.push_back(createVirtualKeyItem(KVC_C, "0x63", "0x43", "0x1a", "0x9f", "blank", "0xbf", "blank"));
		list.push_back(createVirtualKeyItem(KVC_V, "0x76", "0x56", "0x11", "0xeb", "blank", "0xcb", "blank"));
		list.push_back(createVirtualKeyItem(KVC_B, "0x62", "0x42", "0x1b", "0x9a", "blank", "0xba", "blank"));
		list.push_back(createVirtualKeyItem(KVC_N, "0x6e", "0x4e", "blank", "0xf0", "blank", "0xd0", "blank"));
		list.push_back(createVirtualKeyItem(KVC_M, "0x6d", "0x4d", "0x0b", "0xf3", "blank", "0xd3", "blank"));
		list.push_back(createVirtualKeyItem(KVC_COMMA, "0x2c", "0x3c", "0x1f", "0xe8", "0xa4", "0xc8", "0xa4"));
		list.push_back(createVirtualKeyItem(KVC_PERIOD, "0x2e", "0x3e", "0x1d", "0xf9", "0xa1", "0xd9", "0xa1"));
		list.push_back(createVirtualKeyItem(KVC_SLASH, "0x2f", "0x3f", "0x80", "0xf2", "0xa5", "0xd2", "0xa5"));
		list.push_back(createVirtualKeyItem(KVC_RSHIFT, "shift_r", "shift_r", "shift_r", "shift_r", "shift_r", "shift_r", "shift_r", true));
		list.push_back(createVirtualKeyItem(KVC_UP, "up", "up", "up", "up", "up", "up", "up"));
		list.push_back(createVirtualKeyItem(KVC_HIRAGANA, "kana", "kana", "kana", "kana", "kana", "kana", "kana"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}
	{
		std::vector<VirtualKeyItem*> list;
		list.push_back(createVirtualKeyItem(KVC_CAPSLOCK, "caps", "caps", "caps", "caps", "caps", "caps", "caps"));
		list.push_back(createVirtualKeyItem(KVC_LALT, "grph", "grph", "grph", "grph", "grph", "grph", "grph", true));
		list.push_back(createVirtualKeyItem(KVC_SPACE, "space", "space", "space", "space", "space", "space", "space"));
		list.push_back(createVirtualKeyItem(KVC_LEFT, "left", "left", "left", "left", "left", "left", "left"));
		list.push_back(createVirtualKeyItem(KVC_DOWN, "down", "down", "down", "down", "down", "down", "down"));
		list.push_back(createVirtualKeyItem(KVC_RIGHT, "right", "right", "right", "right", "right", "right", "right"));
		alignVirtualKeyItems(list, QPointF(0, unitHeight * i++));
	}

	auto returnKey = createVirtualKeyItem(KVC_ENTER, "return", "return", "return", "return", "return", "return", "return");
	returnKey->setPos(unitWidth * 13.75, unitHeight * 2);

	setSceneRect(itemsBoundingRect());

}
<|endoftext|>


<commit_before>/**
 ******************************************************************************
 * Xenia : Xbox 360 Emulator Research Project                                 *
 ******************************************************************************
 * Copyright 2013 Ben Vanik. All rights reserved.                             *
 * Released under the BSD license - see LICENSE in the root for more details. *
 ******************************************************************************
 */

#include <alloy/backend/ivm/ivm_function.h>

#include <alloy/backend/ivm/ivm_stack.h>
#include <alloy/backend/tracing.h>
#include <alloy/runtime/runtime.h>
#include <alloy/runtime/thread_state.h>

using namespace alloy;
using namespace alloy::backend;
using namespace alloy::backend::ivm;
using namespace alloy::runtime;

IVMFunction::IVMFunction(FunctionInfo* symbol_info) :
    register_count_(0), intcode_count_(0), intcodes_(0),
    source_map_count_(0), source_map_(0),
    GuestFunction(symbol_info) {
}

IVMFunction::~IVMFunction() {
  xe_free(intcodes_);
  xe_free(source_map_);
}

void IVMFunction::Setup(TranslationContext& ctx) {
  register_count_ = ctx.register_count;
  intcode_count_ = ctx.intcode_count;
  intcodes_ = (IntCode*)ctx.intcode_arena->CloneContents();
  source_map_count_ = ctx.source_map_count;
  source_map_ = (SourceMapEntry*)ctx.source_map_arena->CloneContents();
}

IntCode* IVMFunction::GetIntCodeAtSourceOffset(uint64_t offset) {
  for (size_t n = 0; n < source_map_count_; n++) {
    auto entry = &source_map_[n];
    if (entry->source_offset == offset) {
      return &intcodes_[entry->intcode_index];
    }
  }
  return NULL;
}

int IVMFunction::AddBreakpointImpl(Breakpoint* breakpoint) {
  auto i = GetIntCodeAtSourceOffset(breakpoint->address());
  if (!i) {
    return 1;
  }

  // TEMP breakpoints always overwrite normal ones.
  if (!i->debug_flags ||
      breakpoint->type() == Breakpoint::TEMP_TYPE) {
    uint64_t breakpoint_ptr = (uint64_t)breakpoint;
    i->src2_reg = (uint32_t)breakpoint_ptr;
    i->src3_reg = (uint32_t)(breakpoint_ptr >> 32);
  }

  // Increment breakpoint counter.
  ++i->debug_flags;

  return 0;
}

int IVMFunction::RemoveBreakpointImpl(Breakpoint* breakpoint) {
  auto i = GetIntCodeAtSourceOffset(breakpoint->address());
  if (!i) {
    return 1;
  }

  // Decrement breakpoint counter.
  --i->debug_flags;
  i->src2_reg = i->src3_reg = 0;

  // If there were other breakpoints, see what they were.
  if (i->debug_flags) {
    auto old_breakpoint = FindBreakpoint(breakpoint->address());
    if (old_breakpoint) {
      uint64_t breakpoint_ptr = (uint64_t)old_breakpoint;
      i->src2_reg = (uint32_t)breakpoint_ptr;
      i->src3_reg = (uint32_t)(breakpoint_ptr >> 32);
    }
  }

  return 0;
}

void IVMFunction::OnBreakpointHit(ThreadState* thread_state, IntCode* i) {
  uint64_t breakpoint_ptr = i->src2_reg | (uint64_t(i->src3_reg) << 32);
  Breakpoint* breakpoint = (Breakpoint*)breakpoint_ptr;

  // Notify debugger.
  // The debugger may choose to wait (blocking us).
  auto debugger = thread_state->runtime()->debugger();
  debugger->OnBreakpointHit(thread_state, breakpoint);
}

int IVMFunction::CallImpl(ThreadState* thread_state, uint64_t return_address) {
  // Setup register file on stack.
  auto stack = (IVMStack*)thread_state->backend_data();
  auto register_file = (Register*)stack->Alloc(register_count_);

  Memory* memory = thread_state->memory();

  IntCodeState ics;
  ics.rf = register_file;
  ics.context = (uint8_t*)thread_state->raw_context();
  ics.membase = memory->membase();
  ics.reserve_address = memory->reserve_address();
  ics.did_carry = 0;
  ics.did_saturate = 0;
  ics.access_callbacks = thread_state->runtime()->access_callbacks();
  ics.thread_state = thread_state;
  ics.return_address = return_address;
  ics.call_return_address = 0;

  volatile int* suspend_flag_address = thread_state->suspend_flag_address();

  // TODO(benvanik): DID_CARRY -- need HIR to set a OPCODE_FLAG_SET_CARRY
  //                 or something so the fns can set an ics flag.

#ifdef XE_DEBUG
  size_t source_index = 0;
#endif

  uint32_t ia = 0;
  while (true) {
    // Check suspend. We could do this only on certain instructions, if we
    // wanted to speed things up.
    if (*suspend_flag_address) {
      thread_state->EnterSuspend();
    }

#ifdef XE_DEBUG
    uint64_t source_offset = -1;
    if (source_index < this->source_map_count_ &&
        this->source_map_[source_index].intcode_index <= ia)
    {
      while (source_index + 1 < this->source_map_count_ &&
             this->source_map_[source_index + 1].intcode_index <= ia)
      {
        source_index++;
      }
      source_offset = this->source_map_[source_index].source_offset;
    }
#endif

    IntCode* i = &intcodes_[ia];

    if (i->debug_flags) {
      OnBreakpointHit(thread_state, i);
    }

    uint32_t new_ia = i->intcode_fn(ics, i);
    if (new_ia == IA_NEXT) {
      ia++;
    } else if (new_ia == IA_RETURN) {
      break;
    } else {
      ia = new_ia;
#ifdef XE_DEBUG
      source_index = 0;
#endif
    }
  }

  stack->Free(register_count_);

  return 0;
}
<commit_msg>I totally did not violate coding conventions in the last commit.<commit_after>/**
 ******************************************************************************
 * Xenia : Xbox 360 Emulator Research Project                                 *
 ******************************************************************************
 * Copyright 2013 Ben Vanik. All rights reserved.                             *
 * Released under the BSD license - see LICENSE in the root for more details. *
 ******************************************************************************
 */

#include <alloy/backend/ivm/ivm_function.h>

#include <alloy/backend/ivm/ivm_stack.h>
#include <alloy/backend/tracing.h>
#include <alloy/runtime/runtime.h>
#include <alloy/runtime/thread_state.h>

using namespace alloy;
using namespace alloy::backend;
using namespace alloy::backend::ivm;
using namespace alloy::runtime;

IVMFunction::IVMFunction(FunctionInfo* symbol_info) :
    register_count_(0), intcode_count_(0), intcodes_(0),
    source_map_count_(0), source_map_(0),
    GuestFunction(symbol_info) {
}

IVMFunction::~IVMFunction() {
  xe_free(intcodes_);
  xe_free(source_map_);
}

void IVMFunction::Setup(TranslationContext& ctx) {
  register_count_ = ctx.register_count;
  intcode_count_ = ctx.intcode_count;
  intcodes_ = (IntCode*)ctx.intcode_arena->CloneContents();
  source_map_count_ = ctx.source_map_count;
  source_map_ = (SourceMapEntry*)ctx.source_map_arena->CloneContents();
}

IntCode* IVMFunction::GetIntCodeAtSourceOffset(uint64_t offset) {
  for (size_t n = 0; n < source_map_count_; n++) {
    auto entry = &source_map_[n];
    if (entry->source_offset == offset) {
      return &intcodes_[entry->intcode_index];
    }
  }
  return NULL;
}

int IVMFunction::AddBreakpointImpl(Breakpoint* breakpoint) {
  auto i = GetIntCodeAtSourceOffset(breakpoint->address());
  if (!i) {
    return 1;
  }

  // TEMP breakpoints always overwrite normal ones.
  if (!i->debug_flags ||
      breakpoint->type() == Breakpoint::TEMP_TYPE) {
    uint64_t breakpoint_ptr = (uint64_t)breakpoint;
    i->src2_reg = (uint32_t)breakpoint_ptr;
    i->src3_reg = (uint32_t)(breakpoint_ptr >> 32);
  }

  // Increment breakpoint counter.
  ++i->debug_flags;

  return 0;
}

int IVMFunction::RemoveBreakpointImpl(Breakpoint* breakpoint) {
  auto i = GetIntCodeAtSourceOffset(breakpoint->address());
  if (!i) {
    return 1;
  }

  // Decrement breakpoint counter.
  --i->debug_flags;
  i->src2_reg = i->src3_reg = 0;

  // If there were other breakpoints, see what they were.
  if (i->debug_flags) {
    auto old_breakpoint = FindBreakpoint(breakpoint->address());
    if (old_breakpoint) {
      uint64_t breakpoint_ptr = (uint64_t)old_breakpoint;
      i->src2_reg = (uint32_t)breakpoint_ptr;
      i->src3_reg = (uint32_t)(breakpoint_ptr >> 32);
    }
  }

  return 0;
}

void IVMFunction::OnBreakpointHit(ThreadState* thread_state, IntCode* i) {
  uint64_t breakpoint_ptr = i->src2_reg | (uint64_t(i->src3_reg) << 32);
  Breakpoint* breakpoint = (Breakpoint*)breakpoint_ptr;

  // Notify debugger.
  // The debugger may choose to wait (blocking us).
  auto debugger = thread_state->runtime()->debugger();
  debugger->OnBreakpointHit(thread_state, breakpoint);
}

int IVMFunction::CallImpl(ThreadState* thread_state, uint64_t return_address) {
  // Setup register file on stack.
  auto stack = (IVMStack*)thread_state->backend_data();
  auto register_file = (Register*)stack->Alloc(register_count_);

  Memory* memory = thread_state->memory();

  IntCodeState ics;
  ics.rf = register_file;
  ics.context = (uint8_t*)thread_state->raw_context();
  ics.membase = memory->membase();
  ics.reserve_address = memory->reserve_address();
  ics.did_carry = 0;
  ics.did_saturate = 0;
  ics.access_callbacks = thread_state->runtime()->access_callbacks();
  ics.thread_state = thread_state;
  ics.return_address = return_address;
  ics.call_return_address = 0;

  volatile int* suspend_flag_address = thread_state->suspend_flag_address();

  // TODO(benvanik): DID_CARRY -- need HIR to set a OPCODE_FLAG_SET_CARRY
  //                 or something so the fns can set an ics flag.

#ifdef XE_DEBUG
  size_t source_index = 0;
#endif

  uint32_t ia = 0;
  while (true) {
    // Check suspend. We could do this only on certain instructions, if we
    // wanted to speed things up.
    if (*suspend_flag_address) {
      thread_state->EnterSuspend();
    }

#ifdef XE_DEBUG
    uint64_t source_offset = -1;
    if (source_index < this->source_map_count_ &&
        this->source_map_[source_index].intcode_index <= ia) {
      while (source_index + 1 < this->source_map_count_ &&
             this->source_map_[source_index + 1].intcode_index <= ia) {
        source_index++;
      }
      source_offset = this->source_map_[source_index].source_offset;
    }
#endif

    IntCode* i = &intcodes_[ia];

    if (i->debug_flags) {
      OnBreakpointHit(thread_state, i);
    }

    uint32_t new_ia = i->intcode_fn(ics, i);
    if (new_ia == IA_NEXT) {
      ia++;
    } else if (new_ia == IA_RETURN) {
      break;
    } else {
      ia = new_ia;
#ifdef XE_DEBUG
      source_index = 0;
#endif
    }
  }

  stack->Free(register_count_);

  return 0;
}
<|endoftext|>


<commit_before>// Jubatus: Online machine learning framework for distributed environment
// Copyright (C) 2011 Preferred Infrastructure and Nippon Telegraph and Telephone Corporation.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef JUBATUS_CORE_FV_CONVERTER_DATUM_HPP_
#define JUBATUS_CORE_FV_CONVERTER_DATUM_HPP_

#include <map>
#include <string>
#include <utility>
#include <vector>
#include <msgpack.hpp>
#include <pficommon/data/serialization.h>

namespace jubatus {
namespace core {
namespace fv_converter {

struct datum {
  typedef std::vector<std::pair<std::string, std::string> > sv_t;
  typedef std::vector<std::pair<std::string, double> > nv_t;

  sv_t string_values_;
  nv_t num_values_;

  MSGPACK_DEFINE(string_values_, num_values_);

  template<class Archiver>
  void serialize(Archiver& ar) {
    std::map<std::string, std::string> sv;
    std::map<std::string, double> nv;
    if (ar.is_read) {
      ar & NAMED_MEMBER("string_values", sv) & NAMED_MEMBER("num_values", nv);
      string_values_ = sv_t(sv.begin(), sv.end());
      num_values_ = nv_t(nv.begin(), nv.end());
    } else {
      sv.insert(string_values_.begin(), string_values_.end());
      nv.insert(num_values_.begin(), num_values_.end());
      ar & NAMED_MEMBER("string_values", sv) & NAMED_MEMBER("num_values", nv);
    }
  }
};

}  // namespace fv_converter
}  // namespace core
}  // namespace jubatus

#endif  // JUBATUS_CORE_FV_CONVERTER_DATUM_HPP_
<commit_msg>Add binary values<commit_after>// Jubatus: Online machine learning framework for distributed environment
// Copyright (C) 2011 Preferred Infrastructure and Nippon Telegraph and Telephone Corporation.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef JUBATUS_CORE_FV_CONVERTER_DATUM_HPP_
#define JUBATUS_CORE_FV_CONVERTER_DATUM_HPP_

#include <map>
#include <string>
#include <utility>
#include <vector>
#include <msgpack.hpp>
#include <pficommon/data/serialization.h>

namespace jubatus {
namespace core {
namespace fv_converter {

struct datum {
  typedef std::vector<std::pair<std::string, std::string> > sv_t;
  typedef std::vector<std::pair<std::string, double> > nv_t;

  sv_t string_values_;
  nv_t num_values_;
  sv_t binary_values_;

  MSGPACK_DEFINE(string_values_, num_values_, binary_values_);

  template<class Archiver>
  void serialize(Archiver& ar) {
    std::map<std::string, std::string> sv;
    std::map<std::string, double> nv;
    std::map<std::string, std::string> bv;
    if (ar.is_read) {
      ar
          & NAMED_MEMBER("string_values", sv)
          & NAMED_MEMBER("num_values", nv)
          & NAMED_MEMBER("binary_values", bv);
      string_values_ = sv_t(sv.begin(), sv.end());
      num_values_ = nv_t(nv.begin(), nv.end());
      binary_values_ = sv_t(bv.begin(), bv.end());
    } else {
      sv.insert(string_values_.begin(), string_values_.end());
      nv.insert(num_values_.begin(), num_values_.end());
      bv.insert(binary_values_.begin(), binary_values_.end());
      ar
          & NAMED_MEMBER("string_values", sv)
          & NAMED_MEMBER("num_values", nv)
          & NAMED_MEMBER("binary_values", bv);
    }
  }
};

}  // namespace fv_converter
}  // namespace core
}  // namespace jubatus

#endif  // JUBATUS_CORE_FV_CONVERTER_DATUM_HPP_
<|endoftext|>


<commit_before>#include "PunchApplication.h"
#include "Vis_Layers.h"

int g_argc;
char **g_argv;

CMusicModule* CPunchApplication::m_pMusicModule = NULL;
CLayerManager* CPunchApplication::m_pLayerManager = NULL;

CPunchApplication::CPunchApplication()
{

}

CPunchApplication::~CPunchApplication()
{

}

void CPunchApplication::Initialize()
{
	InitializeGLFW();
	InitializeGLEW();
	InitializeMusicModule();
	InitializeLayerManager();
}

void CPunchApplication::InitializeMusicModule()
{
	if(MUSIC_MODULE_TYPE == MM_BASS)
		m_pMusicModule = new CBASSModule();

	if(!m_pMusicModule)
	{
		if(MUSIC_MODULE_TYPE == MM_UNDEFINED)
			Exit(APP_ERROR_MUSIC_MODULE_UNDEFINED);
		else
			Exit(APP_ERROR_UNDEFINED);
	}

	if(m_pMusicModule->Initialize() == APP_ERROR_BASS_INIT)
		Exit(APP_ERROR_BASS_INIT);

	PopulatePlaylist();
	m_pMusicModule->MusicPlayNextItem();
}

void CPunchApplication::InitializeLayerManager()
{
	m_pLayerManager = new CLayerManager();

	m_pLayerManager->AddLayer(new CVis_TestLayer1(0.1f, 0.5f, 0.2f, 3, SimpleColor(0.4f,0.6f,1.0f)));
	m_pLayerManager->AddLayer(new CVis_TestLayer1(0.001f, 0.05f, 0.3f, 70, SimpleColor(1.0f,1.0f,1.0f)));
	m_pLayerManager->AddLayer(new CVis_TestLayer1(0.05f, 0.2f, 0.12f, 30, SimpleColor(0.2f,1.0f,0.4f)));

	m_pLayerManager->AddLayer(new CVis_TestLayer1());

	int iCount = 10;
	for(int i=1;i<=iCount;i++)
	{
		int iFreqStep = i * i * 4;
		if(iFreqStep > FFT_DATAARRAY_SIZE)
			break;
		m_pLayerManager->AddLayer(new CVis_CubeWalking(iFreqStep));
	}

	m_pLayerManager->AddLayer(new CVis_Spectrum());
}

void CPunchApplication::PopulatePlaylist()
{
#ifdef _WIN32
	if(g_argc < 2)
	{
		printf("Error: No audio files added.\n");
		//MessageBoxA(glfwGetWin32Window(m_pAppWindow), , "Error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
		Exit(APP_ERROR_PLAYLIST_INVALID,"To use Punch you will have to drag an audio file onto the .exe");
	}
#endif

	for(int i=1;i<g_argc;i++)
	{
		printf("Adding to playlist: %s\n",g_argv[i]);
		m_pMusicModule->PlaylistAddItem(g_argv[i]);
	}
}

void CPunchApplication::InitializeGLEW()
{
	GLenum res = glewInit();
	if (res != GLEW_OK)
	{
		printf("Error: '%s'\n", glewGetErrorString(res));
		Exit(APP_ERROR_GLEW_INIT);
	}
}

void CPunchApplication::InitializeGLFW()
{
	//Initialize GLFW
	if (!glfwInit())
		Exit(APP_ERROR_GLFW_INIT);

	//Window creation
	glfwWindowHint( GLFW_RESIZABLE, GL_FALSE );
#ifdef WINDOW_NO_BORDER
	glfwWindowHint( GLFW_DECORATED, GL_FALSE ); //noborder
#endif

	// Get monitor video mode properties
	const GLFWvidmode* sVideoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());

	//m_pAppWindow = glfwCreateWindow(sVideoMode->width, sVideoMode->height, APP_WINDOW_TITLE, glfwGetPrimaryMonitor(), NULL); //fullscreen
#ifdef WINDOW_HALF_SIZE
	m_pAppWindow = glfwCreateWindow((int)(sVideoMode->width / 1.5), (int)(sVideoMode->height / 1.5), APP_WINDOW_TITLE, NULL, NULL);
#else
	m_pAppWindow = glfwCreateWindow(sVideoMode->width, sVideoMode->height, APP_WINDOW_TITLE, NULL, NULL);
#endif

	if (!m_pAppWindow)
	{
		glfwTerminate();
		Exit(APP_ERROR_GLFW_WINDOW);
	}

	//Make window's context current
	glfwMakeContextCurrent(m_pAppWindow);

	glfwSetKeyCallback(m_pAppWindow,CPunchApplication::HandleKeyEvents);
	glfwSwapInterval(0);
}

GLuint VBO;					//temp
std::vector<glm::vec3> points;	//temp
void CPunchApplication::MainLoop()
{

	points.push_back(glm::vec3(0.0f,0.0f,0.0f));

	glGenBuffers(1, &VBO);
	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBufferData(GL_ARRAY_BUFFER, points.size() * sizeof(glm::vec3), &points[0], GL_STATIC_DRAW);

	//Loop as long as the window is open
	while (!glfwWindowShouldClose(m_pAppWindow))
	{
		//Logic tick
		if(GetDeltaTime() > (1.0/60.0))
		{
			HandleLogic();

			HandleDraw();

			UpdateDeltaTime();
		}

		//Poll events
		glfwPollEvents();
	}

	points.clear();
}

void CPunchApplication::HandleLogic()
{
	if(m_pMusicModule)
	{
		m_pMusicModule->Think();
		if(m_pLayerManager)
			m_pLayerManager->UpdateLayers(m_pMusicModule->GetFFTData());
	}
}

unsigned int iUnfocusedDrawController = 0;
void CPunchApplication::HandleDraw()
{
	// Check if window is focused
	if (!glfwGetWindowAttrib(m_pAppWindow, GLFW_FOCUSED))
	{
		iUnfocusedDrawController++;
		if(iUnfocusedDrawController % 2 != 0)
			return;
	}

	// Draw scene
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	m_pLayerManager->DrawLayers();

	glPointSize(4.0f);

	//Swap front and back buffers
	glfwSwapBuffers(m_pAppWindow);
}

void CPunchApplication::HandleKeyEvents(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
		glfwSetWindowShouldClose(window, GL_TRUE);
	if (key == GLFW_KEY_RIGHT && action == GLFW_PRESS)
	{
		if(m_pMusicModule)
			m_pMusicModule->MusicPlayNextItem();
		m_pLayerManager->ResetLayers();
	}
	if (key == GLFW_KEY_LEFT && action == GLFW_PRESS)
	{
		if(m_pMusicModule)
			m_pMusicModule->MusicPlayPreviousItem();
	}
}

double CPunchApplication::GetDeltaTime()
{
	return glfwGetTime() - m_dTimeLastFrame;
}

void CPunchApplication::UpdateDeltaTime()
{
	m_dTimeLastFrame = glfwGetTime();
}

void CPunchApplication::Run()
{
	printf("Starting %s!\n", APP_WINDOW_TITLE);
	Initialize();
	MainLoop();
}

void CPunchApplication::Exit()
{
	exit(0);
}

void CPunchApplication::Exit(int iErrorCode)
{
	printf("Exiting with error code %i\n", iErrorCode);
#ifdef _WIN32
	char cErrorMsg[128];
	sprintf_s(cErrorMsg,128,"Code: %i",iErrorCode);
	if(cErrorMsg)
	{
		MessageBoxA(glfwGetWin32Window(m_pAppWindow), cErrorMsg, "Error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
	}
#endif
	exit(iErrorCode);
}

void CPunchApplication::Exit(int iErrorCode, const char* cErrorMessage)
{
	printf("Exiting with error code %i\n", iErrorCode);
#ifdef _WIN32
	char cErrorMsg[128];
	sprintf_s(cErrorMsg,128,"Code: %i\nMessage: %s",iErrorCode,cErrorMessage);
	if(cErrorMsg)
	{
		MessageBoxA(glfwGetWin32Window(m_pAppWindow), cErrorMsg, "Error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
	}
#endif
	exit(iErrorCode);
}

//Entry point
int main(int argc, char *argv[])
{
	g_argc = argc;
	g_argv = argv;

	CPunchApplication cPunchApp;
	cPunchApp.Run(); //Run CPunchApplication
}<commit_msg>Removed focus frame limiter.<commit_after>#include "PunchApplication.h"
#include "Vis_Layers.h"

int g_argc;
char **g_argv;

CMusicModule* CPunchApplication::m_pMusicModule = NULL;
CLayerManager* CPunchApplication::m_pLayerManager = NULL;

CPunchApplication::CPunchApplication()
{

}

CPunchApplication::~CPunchApplication()
{

}

void CPunchApplication::Initialize()
{
	InitializeGLFW();
	InitializeGLEW();
	InitializeMusicModule();
	InitializeLayerManager();
}

void CPunchApplication::InitializeMusicModule()
{
	if(MUSIC_MODULE_TYPE == MM_BASS)
		m_pMusicModule = new CBASSModule();

	if(!m_pMusicModule)
	{
		if(MUSIC_MODULE_TYPE == MM_UNDEFINED)
			Exit(APP_ERROR_MUSIC_MODULE_UNDEFINED);
		else
			Exit(APP_ERROR_UNDEFINED);
	}

	if(m_pMusicModule->Initialize() == APP_ERROR_BASS_INIT)
		Exit(APP_ERROR_BASS_INIT);

	PopulatePlaylist();
	m_pMusicModule->MusicPlayNextItem();
}

void CPunchApplication::InitializeLayerManager()
{
	m_pLayerManager = new CLayerManager();

	m_pLayerManager->AddLayer(new CVis_TestLayer1(0.1f, 0.5f, 0.2f, 3, SimpleColor(0.4f,0.6f,1.0f)));
	m_pLayerManager->AddLayer(new CVis_TestLayer1(0.001f, 0.05f, 0.3f, 70, SimpleColor(1.0f,1.0f,1.0f)));
	m_pLayerManager->AddLayer(new CVis_TestLayer1(0.05f, 0.2f, 0.12f, 30, SimpleColor(0.2f,1.0f,0.4f)));

	m_pLayerManager->AddLayer(new CVis_TestLayer1());

	int iCount = 10;
	for(int i=1;i<=iCount;i++)
	{
		int iFreqStep = i * i * 4;
		if(iFreqStep > FFT_DATAARRAY_SIZE)
			break;
		m_pLayerManager->AddLayer(new CVis_CubeWalking(iFreqStep));
	}

	m_pLayerManager->AddLayer(new CVis_Spectrum());
}

void CPunchApplication::PopulatePlaylist()
{
#ifdef _WIN32
	if(g_argc < 2)
	{
		printf("Error: No audio files added.\n");
		//MessageBoxA(glfwGetWin32Window(m_pAppWindow), , "Error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
		Exit(APP_ERROR_PLAYLIST_INVALID,"To use Punch you will have to drag an audio file onto the .exe");
	}
#endif

	for(int i=1;i<g_argc;i++)
	{
		printf("Adding to playlist: %s\n",g_argv[i]);
		m_pMusicModule->PlaylistAddItem(g_argv[i]);
	}
}

void CPunchApplication::InitializeGLEW()
{
	GLenum res = glewInit();
	if (res != GLEW_OK)
	{
		printf("Error: '%s'\n", glewGetErrorString(res));
		Exit(APP_ERROR_GLEW_INIT);
	}
}

void CPunchApplication::InitializeGLFW()
{
	//Initialize GLFW
	if (!glfwInit())
		Exit(APP_ERROR_GLFW_INIT);

	//Window creation
	glfwWindowHint( GLFW_RESIZABLE, GL_FALSE );
#ifdef WINDOW_NO_BORDER
	glfwWindowHint( GLFW_DECORATED, GL_FALSE ); //noborder
#endif

	// Get monitor video mode properties
	const GLFWvidmode* sVideoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());

	//m_pAppWindow = glfwCreateWindow(sVideoMode->width, sVideoMode->height, APP_WINDOW_TITLE, glfwGetPrimaryMonitor(), NULL); //fullscreen
#ifdef WINDOW_HALF_SIZE
	m_pAppWindow = glfwCreateWindow((int)(sVideoMode->width / 1.5), (int)(sVideoMode->height / 1.5), APP_WINDOW_TITLE, NULL, NULL);
#else
	m_pAppWindow = glfwCreateWindow(sVideoMode->width, sVideoMode->height, APP_WINDOW_TITLE, NULL, NULL);
#endif

	if (!m_pAppWindow)
	{
		glfwTerminate();
		Exit(APP_ERROR_GLFW_WINDOW);
	}

	//Make window's context current
	glfwMakeContextCurrent(m_pAppWindow);

	glfwSetKeyCallback(m_pAppWindow,CPunchApplication::HandleKeyEvents);
	glfwSwapInterval(0);
}

GLuint VBO;					//temp
std::vector<glm::vec3> points;	//temp
void CPunchApplication::MainLoop()
{

	points.push_back(glm::vec3(0.0f,0.0f,0.0f));

	glGenBuffers(1, &VBO);
	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBufferData(GL_ARRAY_BUFFER, points.size() * sizeof(glm::vec3), &points[0], GL_STATIC_DRAW);

	//Loop as long as the window is open
	while (!glfwWindowShouldClose(m_pAppWindow))
	{
		//Logic tick
		if(GetDeltaTime() > (1.0/60.0))
		{
			HandleLogic();

			HandleDraw();

			UpdateDeltaTime();
		}

		//Poll events
		glfwPollEvents();
	}

	points.clear();
}

void CPunchApplication::HandleLogic()
{
	if(m_pMusicModule)
	{
		m_pMusicModule->Think();
		if(m_pLayerManager)
			m_pLayerManager->UpdateLayers(m_pMusicModule->GetFFTData());
	}
}

void CPunchApplication::HandleDraw()
{
	// Draw scene
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	m_pLayerManager->DrawLayers();

	glPointSize(4.0f);

	//Swap front and back buffers
	glfwSwapBuffers(m_pAppWindow);
}

void CPunchApplication::HandleKeyEvents(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
		glfwSetWindowShouldClose(window, GL_TRUE);
	if (key == GLFW_KEY_RIGHT && action == GLFW_PRESS)
	{
		if(m_pMusicModule)
			m_pMusicModule->MusicPlayNextItem();
		m_pLayerManager->ResetLayers();
	}
	if (key == GLFW_KEY_LEFT && action == GLFW_PRESS)
	{
		if(m_pMusicModule)
			m_pMusicModule->MusicPlayPreviousItem();
	}
}

double CPunchApplication::GetDeltaTime()
{
	return glfwGetTime() - m_dTimeLastFrame;
}

void CPunchApplication::UpdateDeltaTime()
{
	m_dTimeLastFrame = glfwGetTime();
}

void CPunchApplication::Run()
{
	printf("Starting %s!\n", APP_WINDOW_TITLE);
	Initialize();
	MainLoop();
}

void CPunchApplication::Exit()
{
	exit(0);
}

void CPunchApplication::Exit(int iErrorCode)
{
	printf("Exiting with error code %i\n", iErrorCode);
#ifdef _WIN32
	char cErrorMsg[128];
	sprintf_s(cErrorMsg,128,"Code: %i",iErrorCode);
	if(cErrorMsg)
	{
		MessageBoxA(glfwGetWin32Window(m_pAppWindow), cErrorMsg, "Error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
	}
#endif
	exit(iErrorCode);
}

void CPunchApplication::Exit(int iErrorCode, const char* cErrorMessage)
{
	printf("Exiting with error code %i\n", iErrorCode);
#ifdef _WIN32
	char cErrorMsg[128];
	sprintf_s(cErrorMsg,128,"Code: %i\nMessage: %s",iErrorCode,cErrorMessage);
	if(cErrorMsg)
	{
		MessageBoxA(glfwGetWin32Window(m_pAppWindow), cErrorMsg, "Error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
	}
#endif
	exit(iErrorCode);
}

//Entry point
int main(int argc, char *argv[])
{
	g_argc = argc;
	g_argv = argv;

	CPunchApplication cPunchApp;
	cPunchApp.Run(); //Run CPunchApplication
}<|endoftext|>


<commit_before>#include <qheaderview.h>
#include <qsplitter.h>
#include <QHBoxLayout>
#include <kapplication.h>
#include <kmainwindow.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kurl.h>
#include <ksystemtimezone.h>
#include <QLineEdit>

#include <akonadi/collection.h>
#include <akonadi/collectionview.h>
#include <akonadi/collectionfilterproxymodel.h>
#include <akonadi/collectionmodel.h>
#include <akonadi/collectionview.h>
#include <akonadi/collectiondeletejob.h>
#include <akonadi/itemmodel.h>
#include <akonadi/itemview.h>
#include <akonadi/standardactionmanager.h>
#include <akonadi/agenttypedialog.h>
#include <akonadi/agentinstancewidget.h>
#include <akonadi/agentmanager.h>
#include <akonadi/agentinstancecreatejob.h>
#include <akonadi/agentfilterproxymodel.h>
#include <akonadi/control.h>
#include <akonadi/itemfetchscope.h>

#include <KCal/Incidence>

#include "akonadicalendar.h"
#include "calendarbase.h"

#include "kotodoeditor.h"
#include "koeventeditor.h"
#include "kojournaleditor.h"

class AKONADI_KCAL_EXPORT CalItemModel : public Akonadi::ItemModel
{
  public:
    explicit CalItemModel(QObject *parent = 0) : Akonadi::ItemModel(parent) { fetchScope().fetchFullPayload(); }
    virtual ~CalItemModel() {}
    virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const {
      return ItemModel::rowCount(parent);
    }
    virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const {
      return 4;
    }
    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const {
      if(role == Qt::DisplayRole) {
        const Akonadi::Item item = itemForIndex(index);
        const Incidence::Ptr incidence = item.hasPayload<Incidence::Ptr>() ? item.payload<Incidence::Ptr>() : Incidence::Ptr();
        if( ! incidence )
          return QVariant();
        switch( index.column() ) {
          case 0: return incidence->type(); break;
          case 1: return incidence->dtStart().toString(); break;
          case 2: return incidence->dtEnd().toString(); break;
          case 3: return incidence->summary(); break;
        }
      }
      return Akonadi::ItemModel::data(index, role);
    }
    virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const {
      if(role == Qt::DisplayRole) {
        switch(section) {
          case 0: return QLatin1String("Type"); break;
          case 1: return QLatin1String("Start"); break;
          case 2: return QLatin1String("End"); break;
          case 3: return QLatin1String("Summary"); break;
        }
      }
      return Akonadi::ItemModel::headerData(section, orientation, role);
    }
    virtual QStringList mimeTypes() const {
      return QStringList()
        << QLatin1String("text/uri-list")
        << QLatin1String("application/x-vnd.akonadi.calendar.event")
        << QLatin1String("application/x-vnd.akonadi.calendar.todo")
        << QLatin1String("application/x-vnd.akonadi.calendar.journal")
        << QLatin1String("application/x-vnd.akonadi.calendar.freebusy");
    }
};

class MainWidget : public QWidget
{
    Q_OBJECT
  public:
    explicit MainWidget(QWidget *parent)
      : QWidget(parent)
      , m_collectionmodel(new Akonadi::CollectionModel(this))
      , m_collectionproxymodel(new Akonadi::CollectionFilterProxyModel(this))
      , m_itemmodel(new CalItemModel(this))
    {
      m_collectionproxymodel->setSourceModel(m_collectionmodel);
      m_collectionproxymodel->addMimeTypeFilter( QString::fromLatin1( "text/calendar" ) );

      Akonadi::ItemFetchScope fetchscope;
      fetchscope.fetchFullPayload(true);
      m_itemmodel->setFetchScope(fetchscope);

      QLayout *layout = new QVBoxLayout(this);
      layout->setMargin(0);
      layout->setSpacing(0);
      this->setLayout(layout);

      QSplitter *splitter = new QSplitter(this);
      layout->addWidget(splitter);
      m_collectionview = new Akonadi::CollectionView(splitter);
      m_collectionview->header()->hide();
      m_collectionview->setModel(m_collectionproxymodel);
      m_collectionview->setRootIsDecorated(true);

      QWidget *mainwidget = new QWidget(splitter);
      QLayout *mainlayout = new QVBoxLayout(mainwidget);
      mainlayout->setMargin(0);
      mainlayout->setSpacing(0);
      mainwidget->setLayout(mainlayout);

      QLineEdit *edit = new QLineEdit(this);
      connect(edit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
      mainlayout->addWidget(edit);

      m_itemview = new Akonadi::ItemView(mainwidget);
      mainlayout->addWidget(m_itemview);
      m_itemproxymodel = new QSortFilterProxyModel(m_itemview);
      m_itemproxymodel->setFilterKeyColumn(3);
      m_itemproxymodel->setSourceModel(m_itemmodel);
      m_itemview->setModel(m_itemproxymodel);

      splitter->setStretchFactor(1, 1);
      selectionChanged();
      connect( m_collectionview->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged()) );
      connect( m_itemview, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated()) );
    }
    virtual ~MainWidget() {}

  private Q_SLOTS:

    void filterChanged(const QString &text) {
      m_itemproxymodel->setFilterWildcard(text);
    }

    void selectionChanged() {
      if(m_collectionview->selectionModel()->hasSelection()) {
        QModelIndex index = m_collectionview->selectionModel()->currentIndex();
        Q_ASSERT( index.isValid() );
        Akonadi::Collection collection = index.model()->data( index, Akonadi::CollectionModel::CollectionRole ).value<Akonadi::Collection>();
        Q_ASSERT( collection.isValid() );
        m_itemmodel->setCollection( collection );
      } else {
        m_itemmodel->setCollection( Akonadi::Collection::root() );
      }
    }

    void itemActivated() {
      QModelIndex index = m_itemview->selectionModel()->currentIndex();
      Q_ASSERT( index.isValid() );
      Akonadi::Item item = index.model()->data( index, Akonadi::ItemModel::ItemRole ).value<Akonadi::Item>();
      //const Akonadi::Item::Id uid = item.id();
      Q_ASSERT( item.isValid() );
      Q_ASSERT( item.hasPayload<KCal::Incidence::Ptr>() );
      const KCal::Incidence::Ptr incidence = item.payload<KCal::Incidence::Ptr>();
      kDebug() << "Add akonadi id=" << item.id() << "uid=" << incidence->uid() << "summary=" << incidence->summary() << "type=" << incidence->type();

      KOrg::CalendarBase *calendar = new KOrg::AkonadiCalendar(KSystemTimeZones::local());

      if(incidence->type() == "Event") {
        KOEventEditor *editor = new KOEventEditor(this);
        editor->init();
        editor->readEvent(item);
        editor->editIncidence(item);
        editor->show();
      } else if(incidence->type() == "Todo") {
        KOTodoEditor *editor = new KOTodoEditor(this);
        editor->init();
        /*
        createCategoryEditor();
        connect( editor, SIGNAL(deleteIncidenceSignal(Incidence *)), mMainView, SLOT(deleteIncidence(Incidence *)) );
        connect( mCategoryEditDialog, SIGNAL(categoryConfigChanged()), editor, SIGNAL(updateCategoryConfig()) );
        connect( editor, SIGNAL(editCategories()), mCategoryEditDialog, SLOT(show()) );
        connect( editor, SIGNAL(dialogClose(Incidence *)), mMainView, SLOT(dialogClosing(Incidence *)) );
        connect( editor, SIGNAL(editCanceled(Incidence *)), mMainView, SLOT(editCanceled(Incidence *)) );
        connect( mMainView, SIGNAL(closingDown()), editor, SLOT(reject()) );
        connect( editor, SIGNAL(deleteAttendee(Incidence *)), mMainView, SIGNAL(cancelAttendees(Incidence *)) );
        */
        editor->readTodo(item);
        editor->editIncidence(item);
        editor->show();

      } else if(incidence->type() == "Journal") {
        KOJournalEditor *editor = new KOJournalEditor(this);
        editor->init();
        editor->readJournal(item);
        editor->editIncidence(item);
        editor->show();
      } else {
        Q_ASSERT(false);
      }
    }

  private:
    Akonadi::CollectionModel *m_collectionmodel;
    Akonadi::CollectionFilterProxyModel *m_collectionproxymodel;
    Akonadi::CollectionView *m_collectionview;
    CalItemModel *m_itemmodel;
    QSortFilterProxyModel *m_itemproxymodel;
    Akonadi::ItemView *m_itemview;
};

int main(int argc, char **argv)
{
    KAboutData about("incidenceeditorapp",
                     "korganizer",
                     ki18n("IncidenceEditorApp"),
                     "0.1",
                     ki18n("KDE application to run the KOrganizer incidenceeditor."),
                     KAboutData::License_LGPL,
                     ki18n("(C) 2009 Sebastian Sauer"),
                     ki18n("Run the KOrganizer incidenceeditor."),
                     "http://kdepim.kde.org",
                     "kdepim@kde.org");
    about.addAuthor(ki18n("Sebastian Sauer"), ki18n("Author"), "sebsauer@kdab.net");
    KCmdLineArgs::init(argc, argv, &about);
    KApplication app;
    KMainWindow *mainwindow = new KMainWindow();
    mainwindow->setCentralWidget( new MainWidget(mainwindow) );
    mainwindow->resize(QSize(800, 600).expandedTo(mainwindow->minimumSizeHint()));
    mainwindow->show();
    return app.exec();
}

#include "main.moc"
<commit_msg>not needed any longer<commit_after>#include <qheaderview.h>
#include <qsplitter.h>
#include <QHBoxLayout>
#include <kapplication.h>
#include <kmainwindow.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kurl.h>
#include <ksystemtimezone.h>
#include <QLineEdit>

#include <akonadi/collection.h>
#include <akonadi/collectionview.h>
#include <akonadi/collectionfilterproxymodel.h>
#include <akonadi/collectionmodel.h>
#include <akonadi/collectionview.h>
#include <akonadi/collectiondeletejob.h>
#include <akonadi/itemmodel.h>
#include <akonadi/itemview.h>
#include <akonadi/standardactionmanager.h>
#include <akonadi/agenttypedialog.h>
#include <akonadi/agentinstancewidget.h>
#include <akonadi/agentmanager.h>
#include <akonadi/agentinstancecreatejob.h>
#include <akonadi/agentfilterproxymodel.h>
#include <akonadi/control.h>
#include <akonadi/itemfetchscope.h>

#include <KCal/Incidence>

#include "akonadicalendar.h"
#include "calendarbase.h"

#include "kotodoeditor.h"
#include "koeventeditor.h"
#include "kojournaleditor.h"

class AKONADI_KCAL_EXPORT CalItemModel : public Akonadi::ItemModel
{
  public:
    explicit CalItemModel(QObject *parent = 0) : Akonadi::ItemModel(parent) { fetchScope().fetchFullPayload(); }
    virtual ~CalItemModel() {}
    virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const {
      return ItemModel::rowCount(parent);
    }
    virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const {
      return 4;
    }
    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const {
      if(role == Qt::DisplayRole) {
        const Akonadi::Item item = itemForIndex(index);
        const Incidence::Ptr incidence = item.hasPayload<Incidence::Ptr>() ? item.payload<Incidence::Ptr>() : Incidence::Ptr();
        if( ! incidence )
          return QVariant();
        switch( index.column() ) {
          case 0: return incidence->type(); break;
          case 1: return incidence->dtStart().toString(); break;
          case 2: return incidence->dtEnd().toString(); break;
          case 3: return incidence->summary(); break;
        }
      }
      return Akonadi::ItemModel::data(index, role);
    }
    virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const {
      if(role == Qt::DisplayRole) {
        switch(section) {
          case 0: return QLatin1String("Type"); break;
          case 1: return QLatin1String("Start"); break;
          case 2: return QLatin1String("End"); break;
          case 3: return QLatin1String("Summary"); break;
        }
      }
      return Akonadi::ItemModel::headerData(section, orientation, role);
    }
    virtual QStringList mimeTypes() const {
      return QStringList()
        << QLatin1String("text/uri-list")
        << QLatin1String("application/x-vnd.akonadi.calendar.event")
        << QLatin1String("application/x-vnd.akonadi.calendar.todo")
        << QLatin1String("application/x-vnd.akonadi.calendar.journal")
        << QLatin1String("application/x-vnd.akonadi.calendar.freebusy");
    }
};

class MainWidget : public QWidget
{
    Q_OBJECT
  public:
    explicit MainWidget(QWidget *parent)
      : QWidget(parent)
      , m_collectionmodel(new Akonadi::CollectionModel(this))
      , m_collectionproxymodel(new Akonadi::CollectionFilterProxyModel(this))
      , m_itemmodel(new CalItemModel(this))
    {
      m_collectionproxymodel->setSourceModel(m_collectionmodel);
      m_collectionproxymodel->addMimeTypeFilter( QString::fromLatin1( "text/calendar" ) );

      Akonadi::ItemFetchScope fetchscope;
      fetchscope.fetchFullPayload(true);
      m_itemmodel->setFetchScope(fetchscope);

      QLayout *layout = new QVBoxLayout(this);
      layout->setMargin(0);
      layout->setSpacing(0);
      this->setLayout(layout);

      QSplitter *splitter = new QSplitter(this);
      layout->addWidget(splitter);
      m_collectionview = new Akonadi::CollectionView(splitter);
      m_collectionview->header()->hide();
      m_collectionview->setModel(m_collectionproxymodel);
      m_collectionview->setRootIsDecorated(true);

      QWidget *mainwidget = new QWidget(splitter);
      QLayout *mainlayout = new QVBoxLayout(mainwidget);
      mainlayout->setMargin(0);
      mainlayout->setSpacing(0);
      mainwidget->setLayout(mainlayout);

      QLineEdit *edit = new QLineEdit(this);
      connect(edit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
      mainlayout->addWidget(edit);

      m_itemview = new Akonadi::ItemView(mainwidget);
      mainlayout->addWidget(m_itemview);
      m_itemproxymodel = new QSortFilterProxyModel(m_itemview);
      m_itemproxymodel->setFilterKeyColumn(3);
      m_itemproxymodel->setSourceModel(m_itemmodel);
      m_itemview->setModel(m_itemproxymodel);

      splitter->setStretchFactor(1, 1);
      selectionChanged();
      connect( m_collectionview->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged()) );
      connect( m_itemview, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated()) );
    }
    virtual ~MainWidget() {}

  private Q_SLOTS:

    void filterChanged(const QString &text) {
      m_itemproxymodel->setFilterWildcard(text);
    }

    void selectionChanged() {
      if(m_collectionview->selectionModel()->hasSelection()) {
        QModelIndex index = m_collectionview->selectionModel()->currentIndex();
        Q_ASSERT( index.isValid() );
        Akonadi::Collection collection = index.model()->data( index, Akonadi::CollectionModel::CollectionRole ).value<Akonadi::Collection>();
        Q_ASSERT( collection.isValid() );
        m_itemmodel->setCollection( collection );
      } else {
        m_itemmodel->setCollection( Akonadi::Collection::root() );
      }
    }

    void itemActivated() {
      QModelIndex index = m_itemview->selectionModel()->currentIndex();
      Q_ASSERT( index.isValid() );
      Akonadi::Item item = index.model()->data( index, Akonadi::ItemModel::ItemRole ).value<Akonadi::Item>();
      //const Akonadi::Item::Id uid = item.id();
      Q_ASSERT( item.isValid() );
      Q_ASSERT( item.hasPayload<KCal::Incidence::Ptr>() );
      const KCal::Incidence::Ptr incidence = item.payload<KCal::Incidence::Ptr>();
      kDebug() << "Add akonadi id=" << item.id() << "uid=" << incidence->uid() << "summary=" << incidence->summary() << "type=" << incidence->type();

      if(incidence->type() == "Event") {
        KOEventEditor *editor = new KOEventEditor(this);
        editor->init();
        editor->readEvent(item);
        editor->editIncidence(item);
        editor->show();
      } else if(incidence->type() == "Todo") {
        KOTodoEditor *editor = new KOTodoEditor(this);
        editor->init();
        /*
        createCategoryEditor();
        connect( editor, SIGNAL(deleteIncidenceSignal(Incidence *)), mMainView, SLOT(deleteIncidence(Incidence *)) );
        connect( mCategoryEditDialog, SIGNAL(categoryConfigChanged()), editor, SIGNAL(updateCategoryConfig()) );
        connect( editor, SIGNAL(editCategories()), mCategoryEditDialog, SLOT(show()) );
        connect( editor, SIGNAL(dialogClose(Incidence *)), mMainView, SLOT(dialogClosing(Incidence *)) );
        connect( editor, SIGNAL(editCanceled(Incidence *)), mMainView, SLOT(editCanceled(Incidence *)) );
        connect( mMainView, SIGNAL(closingDown()), editor, SLOT(reject()) );
        connect( editor, SIGNAL(deleteAttendee(Incidence *)), mMainView, SIGNAL(cancelAttendees(Incidence *)) );
        */
        editor->readTodo(item);
        editor->editIncidence(item);
        editor->show();

      } else if(incidence->type() == "Journal") {
        KOJournalEditor *editor = new KOJournalEditor(this);
        editor->init();
        editor->readJournal(item);
        editor->editIncidence(item);
        editor->show();
      } else {
        Q_ASSERT(false);
      }
    }

  private:
    Akonadi::CollectionModel *m_collectionmodel;
    Akonadi::CollectionFilterProxyModel *m_collectionproxymodel;
    Akonadi::CollectionView *m_collectionview;
    CalItemModel *m_itemmodel;
    QSortFilterProxyModel *m_itemproxymodel;
    Akonadi::ItemView *m_itemview;
};

int main(int argc, char **argv)
{
    KAboutData about("incidenceeditorapp",
                     "korganizer",
                     ki18n("IncidenceEditorApp"),
                     "0.1",
                     ki18n("KDE application to run the KOrganizer incidenceeditor."),
                     KAboutData::License_LGPL,
                     ki18n("(C) 2009 Sebastian Sauer"),
                     ki18n("Run the KOrganizer incidenceeditor."),
                     "http://kdepim.kde.org",
                     "kdepim@kde.org");
    about.addAuthor(ki18n("Sebastian Sauer"), ki18n("Author"), "sebsauer@kdab.net");
    KCmdLineArgs::init(argc, argv, &about);
    KApplication app;
    KMainWindow *mainwindow = new KMainWindow();
    mainwindow->setCentralWidget( new MainWidget(mainwindow) );
    mainwindow->resize(QSize(800, 600).expandedTo(mainwindow->minimumSizeHint()));
    mainwindow->show();
    return app.exec();
}

#include "main.moc"
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: ScriptSecurityManager.cxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: dfoster $ $Date: 2003-01-28 17:09:26 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/util/XStringSubstitution.hpp>
#include "ScriptSecurityManager.hxx"
#include <util/util.hxx>
#include <util/scriptingconstants.hxx>

using namespace ::rtl;
using namespace ::osl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
//using namespace ::drafts::com::sun::star::script::framework;

namespace scripting_securitymgr
{

static OUString s_configProv = ::rtl::OUString::createFromAscii(
    "com.sun.star.configuration.ConfigurationProvider");

static OUString s_configAccess = ::rtl::OUString::createFromAscii(
    "com.sun.star.configuration.ConfigurationAccess");

//*************************************************************************
// ScriptSecurityManager Constructor
ScriptSecurityManager::ScriptSecurityManager(
    const Reference< XComponentContext > & xContext ) throw ( RuntimeException )
    : m_xContext( xContext)
{
    OSL_TRACE( "< ScriptSecurityManager ctor called >\n" );
    validateXRef( m_xContext,
        "ScriptSecurityManager::ScriptSecurityManager: invalid context" );
    // test purposes only
    readConfiguration();
}

void ScriptSecurityManager::addScriptStorage( rtl::OUString url,
    sal_Int32 storageID)
{
    readConfiguration();
    StoragePerm newPerm;
    newPerm.url=url;
    newPerm.storageID=storageID;

    // we err on the side of caution!!
    newPerm.execPermission=false;
    switch( m_officeBasic )
    {
        case 0:         // never
            break;
        case 1:         // according to path list
            // check path
            rtl::OUString path = url.copy( 0, url.lastIndexOf( '/' ) );
            for(int j=m_secureURL.getLength();j>0;j--)
            {
                if( path.equals( m_secureURL[j-1] ) )
                {
                    newPerm.execPermission=true;
                    break;
                }
            }
            // confirm dialog
            break;
        case 2:         // always
            newPerm.execPermission=true;
            break;
        default:
            //
            throw RuntimeException(
                OUSTR( "ScriptSecurityManager::addScriptStorage got invalid OfficeBasic setting"),
                Reference< XInterface > ());
    }
    m_permissionSettings.push_back(newPerm);
}
/**
 * checks to see whether the requested ScriptPeremission is allowed.
 * This was modelled after the Java AccessController, but at this time
 * we can't see a good reason not to return a bool, rather than throw
 * an exception if the request is not granted (as is the case in Java).
 */
sal_Bool ScriptSecurityManager::checkPermission( const OUString & scriptStorageURL,
    const OUString & permissionRequest )
    throw ( RuntimeException )
{
    if( permissionRequest.equals( OUString::createFromAscii( "execute" ) ) )
    {
        OSL_TRACE(
            "ScriptSecurityManager::checkPermission: execute permission request for %s",
            ::rtl::OUStringToOString( scriptStorageURI,
                RTL_TEXTENCODING_ASCII_US ).pData->buffer);
        ::std::vector< StoragePerm >::const_iterator iter;
        ::std::vector< StoragePerm >::const_iterator iterEnd =
            m_permissionSettings.end();
        for ( iter = m_permissionSettings.begin() ; iter != iterEnd; ++iter )
        {
            if ( iter->url.equals( scriptStorageURL ) )
            {
                // warning dialog if necessary
                return iter->execPermission;
            }
        }
        // we should never get here!!
        throw RuntimeException( OUString::createFromAscii( "ScriptSecurityManager::checkPermission: storageURL not found" ) );
    }
    else
        return sal_True;
}

void ScriptSecurityManager::readConfiguration()
    throw ( RuntimeException)
{
    // get the serice manager from the context
    Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
    validateXRef( xMgr,
        "ScriptSecurityManager::ScriptSecurityManager: cannot get ServiceManager" );
    // create an instance of the ConfigurationProvider
    Reference< XInterface > xInterface = xMgr->createInstanceWithContext(
        s_configProv, m_xContext );
    validateXRef( xInterface,
        "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationProvider" );
    beans::PropertyValue configPath;
    configPath.Name = ::rtl::OUString::createFromAscii( "nodepath" );
    configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Common/Security/Scripting" );
    Sequence < Any > aargs( 1 );
    aargs[ 0 ] <<= configPath;
    // create an instance of the ConfigurationAccess for accessing the
    // scripting security settings
    Reference < lang::XMultiServiceFactory > xFactory( xInterface, UNO_QUERY );
    validateXRef( xFactory,
        "ScriptSecurityManager::ScriptSecurityManager: cannot get XMultiServiceFactory interface from ConfigurationProvider" );
    xInterface = xFactory->createInstanceWithArguments( s_configAccess,
            aargs );
    validateXRef( xInterface,
        "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationAccess" );
    // get the XPropertySet interface from the ConfigurationAccess service
    Reference < beans::XPropertySet > xPropSet( xInterface, UNO_QUERY );
    Any value;
    value=xPropSet->getPropertyValue( OUSTR( "Confirmation" ) );
    if ( sal_False == ( value >>= m_confirmationRequired ) )
    {
        throw RuntimeException(
            OUSTR( "ScriptSecurityManager: can't get Confirmation setting" ),
            Reference< XInterface > () );
    }
    if ( m_confirmationRequired == sal_True )
    {
        OSL_TRACE( "ScriptSecurityManager: confirmation is true" );
    }
    else
    {
        OSL_TRACE( "ScriptSecurityManager: confirmation is false" );
    }
    value=xPropSet->getPropertyValue( OUSTR( "Warning" ) );
    if ( sal_False == ( value >>= m_warning ) )
    {
        throw RuntimeException(
            OUSTR( "ScriptSecurityManager: can't get Warning setting" ),
            Reference< XInterface > () );
    }
    if ( m_warning == sal_True )
    {
        OSL_TRACE( "ScriptSecurityManager: warning is true" );
    }
    else
    {
        OSL_TRACE( "ScriptSecurityManager: warning is false" );
    }
    value=xPropSet->getPropertyValue( OUSTR( "OfficeBasic" ) );
    if ( sal_False == ( value >>= m_officeBasic ) )
    {
        throw RuntimeException(
            OUSTR( "ScriptSecurityManager: can't get OfficeBasic setting" ),
            Reference< XInterface > () );
    }
    OSL_TRACE( "ScriptSecurityManager: OfficeBasic = %d", m_officeBasic );
    value=xPropSet->getPropertyValue( OUSTR( "SecureURL" ) );
    if ( sal_False == ( value >>= m_secureURL ) )
    {
        throw RuntimeException(
            OUSTR( "ScriptSecurityManager: can't get SecureURL setting" ),
            Reference< XInterface > () );
    }
    // need debug output for contents of sequence
    for(int i=m_secureURL.getLength();i>0;i--)
    {
        OSL_TRACE( "ScriptSecurityManager: path = %s",
            ::rtl::OUStringToOString(m_secureURL[i-1] ,
            RTL_TEXTENCODING_ASCII_US ).pData->buffer  );

        xInterface = xMgr->createInstanceWithContext(
            ::rtl::OUString::createFromAscii(
            "com.sun.star.util.PathSubstitution"), m_xContext);
        validateXRef( xInterface,
            "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationProvider" );
        Reference< util::XStringSubstitution > xStringSubstitution(
            xInterface, UNO_QUERY);
        validateXRef( xStringSubstitution,
            "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationProvider" );
        OSL_TRACE( "ScriptSecurityManager: subpath = %s",
            ::rtl::OUStringToOString(
            xStringSubstitution->substituteVariables( m_secureURL[i-1], true ),
            RTL_TEXTENCODING_ASCII_US ).pData->buffer );
        m_secureURL[i-1] = xStringSubstitution->substituteVariables( m_secureURL[i-1], true );
    }
    for(int j=m_secureURL.getLength();j>0;j--)
    {
        OSL_TRACE( "ScriptSecurityManager: path = %s",
            ::rtl::OUStringToOString(m_secureURL[j-1] ,
            RTL_TEXTENCODING_ASCII_US ).pData->buffer  );
    }
}

//*************************************************************************
// ScriptSecurityManager Destructor
ScriptSecurityManager::~ScriptSecurityManager()
{
    OSL_TRACE( "< ScriptSecurityManager dtor called >\n" );
}

} // Namespace
<commit_msg>Changes needed to compile<commit_after>/*************************************************************************
 *
 *  $RCSfile: ScriptSecurityManager.cxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: npower $ $Date: 2003-01-30 16:08:41 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/util/XStringSubstitution.hpp>
#include "ScriptSecurityManager.hxx"
#include <util/util.hxx>
#include <util/scriptingconstants.hxx>

using namespace ::rtl;
using namespace ::osl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
//using namespace ::drafts::com::sun::star::script::framework;

namespace scripting_securitymgr
{

static OUString s_configProv = ::rtl::OUString::createFromAscii(
    "com.sun.star.configuration.ConfigurationProvider");

static OUString s_configAccess = ::rtl::OUString::createFromAscii(
    "com.sun.star.configuration.ConfigurationAccess");

//*************************************************************************
// ScriptSecurityManager Constructor
ScriptSecurityManager::ScriptSecurityManager(
    const Reference< XComponentContext > & xContext ) throw ( RuntimeException )
    : m_xContext( xContext)
{
    OSL_TRACE( "< ScriptSecurityManager ctor called >\n" );
    validateXRef( m_xContext,
        "ScriptSecurityManager::ScriptSecurityManager: invalid context" );
    // test purposes only
    readConfiguration();
}

void ScriptSecurityManager::addScriptStorage( rtl::OUString url,
    sal_Int32 storageID)
{
    readConfiguration();
    StoragePerm newPerm;
    newPerm.url=url;
    newPerm.storageID=storageID;

    // we err on the side of caution!!
    newPerm.execPermission=false;
    switch( m_officeBasic )
    {
        case 0:         // never
            break;
        case 1:         // according to path list
            {
                // check path
                rtl::OUString path = url.copy( 0, url.lastIndexOf( '/' ) );
                for(int j=m_secureURL.getLength();j>0;j--)
                {
                    if( path.equals( m_secureURL[j-1] ) )
                    {
                        newPerm.execPermission=true;
                        break;
                    }
                }
                // confirm dialog
                break;
            }
        case 2:         // always
            newPerm.execPermission=true;
            break;
        default:
            //
            throw RuntimeException(
                OUSTR( "ScriptSecurityManager::addScriptStorage got invalid OfficeBasic setting"),
                Reference< XInterface > ());
    }
    m_permissionSettings.push_back(newPerm);
}
/**
 * checks to see whether the requested ScriptPeremission is allowed.
 * This was modelled after the Java AccessController, but at this time
 * we can't see a good reason not to return a bool, rather than throw
 * an exception if the request is not granted (as is the case in Java).
 */
sal_Bool ScriptSecurityManager::checkPermission( const OUString & scriptStorageURL,
    const OUString & permissionRequest )
    throw ( RuntimeException )
{
    if( permissionRequest.equals( OUString::createFromAscii( "execute" ) ) )
    {
        OSL_TRACE(
            "ScriptSecurityManager::checkPermission: execute permission request for %s",
            ::rtl::OUStringToOString( scriptStorageURL,
                RTL_TEXTENCODING_ASCII_US ).pData->buffer);
        ::std::vector< StoragePerm >::const_iterator iter;
        ::std::vector< StoragePerm >::const_iterator iterEnd =
            m_permissionSettings.end();
        for ( iter = m_permissionSettings.begin() ; iter != iterEnd; ++iter )
        {
            if ( iter->url.equals( scriptStorageURL ) )
            {
                // warning dialog if necessary
                return iter->execPermission;
            }
        }
        // we should never get here!!
        throw RuntimeException( OUString::createFromAscii( "ScriptSecurityManager::checkPermission: storageURL not found" ), Reference< XInterface > () );
    }
    else
        return sal_True;
}

void ScriptSecurityManager::readConfiguration()
    throw ( RuntimeException)
{
    // get the serice manager from the context
    Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
    validateXRef( xMgr,
        "ScriptSecurityManager::ScriptSecurityManager: cannot get ServiceManager" );
    // create an instance of the ConfigurationProvider
    Reference< XInterface > xInterface = xMgr->createInstanceWithContext(
        s_configProv, m_xContext );
    validateXRef( xInterface,
        "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationProvider" );
    beans::PropertyValue configPath;
    configPath.Name = ::rtl::OUString::createFromAscii( "nodepath" );
    configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Common/Security/Scripting" );
    Sequence < Any > aargs( 1 );
    aargs[ 0 ] <<= configPath;
    // create an instance of the ConfigurationAccess for accessing the
    // scripting security settings
    Reference < lang::XMultiServiceFactory > xFactory( xInterface, UNO_QUERY );
    validateXRef( xFactory,
        "ScriptSecurityManager::ScriptSecurityManager: cannot get XMultiServiceFactory interface from ConfigurationProvider" );
    xInterface = xFactory->createInstanceWithArguments( s_configAccess,
            aargs );
    validateXRef( xInterface,
        "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationAccess" );
    // get the XPropertySet interface from the ConfigurationAccess service
    Reference < beans::XPropertySet > xPropSet( xInterface, UNO_QUERY );
    Any value;
    value=xPropSet->getPropertyValue( OUSTR( "Confirmation" ) );
    if ( sal_False == ( value >>= m_confirmationRequired ) )
    {
        throw RuntimeException(
            OUSTR( "ScriptSecurityManager: can't get Confirmation setting" ),
            Reference< XInterface > () );
    }
    if ( m_confirmationRequired == sal_True )
    {
        OSL_TRACE( "ScriptSecurityManager: confirmation is true" );
    }
    else
    {
        OSL_TRACE( "ScriptSecurityManager: confirmation is false" );
    }
    value=xPropSet->getPropertyValue( OUSTR( "Warning" ) );
    if ( sal_False == ( value >>= m_warning ) )
    {
        throw RuntimeException(
            OUSTR( "ScriptSecurityManager: can't get Warning setting" ),
            Reference< XInterface > () );
    }
    if ( m_warning == sal_True )
    {
        OSL_TRACE( "ScriptSecurityManager: warning is true" );
    }
    else
    {
        OSL_TRACE( "ScriptSecurityManager: warning is false" );
    }
    value=xPropSet->getPropertyValue( OUSTR( "OfficeBasic" ) );
    if ( sal_False == ( value >>= m_officeBasic ) )
    {
        throw RuntimeException(
            OUSTR( "ScriptSecurityManager: can't get OfficeBasic setting" ),
            Reference< XInterface > () );
    }
    OSL_TRACE( "ScriptSecurityManager: OfficeBasic = %d", m_officeBasic );
    value=xPropSet->getPropertyValue( OUSTR( "SecureURL" ) );
    if ( sal_False == ( value >>= m_secureURL ) )
    {
        throw RuntimeException(
            OUSTR( "ScriptSecurityManager: can't get SecureURL setting" ),
            Reference< XInterface > () );
    }
    // need debug output for contents of sequence
    for(int i=m_secureURL.getLength();i>0;i--)
    {
        OSL_TRACE( "ScriptSecurityManager: path = %s",
            ::rtl::OUStringToOString(m_secureURL[i-1] ,
            RTL_TEXTENCODING_ASCII_US ).pData->buffer  );

        xInterface = xMgr->createInstanceWithContext(
            ::rtl::OUString::createFromAscii(
            "com.sun.star.util.PathSubstitution"), m_xContext);
        validateXRef( xInterface,
            "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationProvider" );
        Reference< util::XStringSubstitution > xStringSubstitution(
            xInterface, UNO_QUERY);
        validateXRef( xStringSubstitution,
            "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationProvider" );
        OSL_TRACE( "ScriptSecurityManager: subpath = %s",
            ::rtl::OUStringToOString(
            xStringSubstitution->substituteVariables( m_secureURL[i-1], true ),
            RTL_TEXTENCODING_ASCII_US ).pData->buffer );
        m_secureURL[i-1] = xStringSubstitution->substituteVariables( m_secureURL[i-1], true );
    }
    for(int j=m_secureURL.getLength();j>0;j--)
    {
        OSL_TRACE( "ScriptSecurityManager: path = %s",
            ::rtl::OUStringToOString(m_secureURL[j-1] ,
            RTL_TEXTENCODING_ASCII_US ).pData->buffer  );
    }
}

//*************************************************************************
// ScriptSecurityManager Destructor
ScriptSecurityManager::~ScriptSecurityManager()
{
    OSL_TRACE( "< ScriptSecurityManager dtor called >\n" );
}

} // Namespace
<|endoftext|>