public override bool Generate(UPnPDevice[] devices, DirectoryInfo outputDirectory) { StreamWriter W; bool RetVal = false; string SampleApp = null; bool deviceOK = false; bool cpOK = false; string WS = null; string WS2 = null; if (!Configuration.SupressSampleProject) { switch (Configuration.TargetPlatform) { case ServiceGenerator.PLATFORMS.MICROSTACK_POSIX: case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK1: case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK2: SampleApp = SourceCodeRepository.GetMain_C_Template(); break; case ServiceGenerator.PLATFORMS.MICROSTACK_SYMBIANv9_1: SampleApp = SourceCodeRepository.Get_Generic("SAMPLE_CPP"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POCKETPC: SampleApp = SourceCodeRepository.Get_SampleProjectDlg_cpp(); break; } } MasterFriendlyNameTable.Clear(); foreach (UPnPDevice d in devices) { FriendlyName(d); } if (Configuration.CPlusPlusWrapper || Configuration.DynamicObjectModel) { DeviceObjectGenerator.PrepDevice(devices); } #region ILib File Generation SourceCodeRepository.Generate_Parsers(Configuration.prefixlib, outputDirectory); SourceCodeRepository.Generate_AsyncSocket(Configuration.prefixlib, outputDirectory); SourceCodeRepository.Generate_AsyncUDPSocket(Configuration.prefixlib, outputDirectory); SourceCodeRepository.Generate_AsyncServerSocket(Configuration.prefixlib, outputDirectory); SourceCodeRepository.Generate_WebClient(Configuration, outputDirectory); SourceCodeRepository.Generate_WebServer(Configuration, outputDirectory); if (Configuration.GenerateThreadPoolLibrary) { SourceCodeRepository.Generate_ThreadPool(Configuration.prefixlib, outputDirectory); } if (Configuration.TargetPlatform == ServiceGenerator.PLATFORMS.MICROSTACK_SYMBIANv9_1) { SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "ChainAdaptor.h", "CHAINADAPTOR_H"); SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "ChainAdaptor.cpp", "CHAINADAPTOR_CPP"); SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "ChainEngine.h", "CHAINENGINE_H"); SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "ChainEngine.cpp", "CHAINENGINE_CPP"); SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "SocketWrapper.h", "SOCKETWRAPPER_H"); SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "SocketWrapper.cpp", "SOCKETWRAPPER_CPP"); SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "SymbianSemaphore.h", "SYMBIANSEMAPHORE_H"); SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "SymbianSemaphore.cpp", "SYMBIANSEMAPHORE_CPP"); SourceCodeRepository.Generate_Generic(Configuration.prefixlib, outputDirectory, "ChainDefs.h", "CHAINDEFS_H"); } #endregion #region Generate MicroStack files for each device foreach (UPnPDevice device in devices) { if (((ServiceGenerator.Configuration)device.User).ConfigType == ServiceGenerator.ConfigurationType.DEVICE) { if (Configuration.UPNP_1dot1) { device.ArchitectureVersion = "1.1"; device.BootID = "%d"; } else { device.ArchitectureVersion = "1.0"; device.BootID = ""; } device.ClearCustomFieldsInDescription(); ((ServiceGenerator.Configuration)device.User).AddAllCustomFieldsToDevice(device); device.HasPresentation = ((ServiceGenerator.Configuration)device.User).AdvertisesPresentationPage; if (device.HasPresentation) device.PresentationURL = "/web"; RetVal = GenerateEx(device, outputDirectory, GetServiceNameTable(device), ref SampleApp); if (!RetVal) { break; } } } #endregion #region C++ Wrapper Generation if (Configuration.CPlusPlusWrapper) { string CPlusPlus_H = DeviceObjectGenerator.GetCPlusPlusAbstraction_H(devices); #region Prefixes CPlusPlus_H = CPlusPlus_H.Replace("ILib", Configuration.prefixlib); #endregion #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\UPnPAbstraction.h"); W.Write(CPlusPlus_H); W.Close(); #endregion foreach (UPnPDevice d in devices) { FriendlyName(d); } string CPlusPlus_CPP = DeviceObjectGenerator.GetCPlusPlusAbstraction_CPP(devices); #region Prefixes CPlusPlus_CPP = CPlusPlus_CPP.Replace("ILib", Configuration.prefixlib); #endregion #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\UPnPAbstraction.cpp"); W.Write(CPlusPlus_CPP); W.Close(); #endregion } #endregion CPEmbeddedCGenerator gen2 = new CPEmbeddedCGenerator(Configuration, SampleApp); gen2.Generate(devices, outputDirectory); SampleApp = gen2.SampleApplication; if (SampleApp != null) { #region Main.c / SampleProjectDlg.cpp #region Platform if (Configuration.TargetPlatform != ServiceGenerator.PLATFORMS.MICROSTACK_POSIX) { SampleApp = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_POSIX}}}", "//{{{END_POSIX}}}", SampleApp); } else { SampleApp = SourceCodeRepository.RemoveTag("//{{{BEGIN_POSIX}}}", "//{{{END_POSIX}}}", SampleApp); } if (Configuration.TargetPlatform == ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK1 || Configuration.TargetPlatform == ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK2 || Configuration.TargetPlatform == ServiceGenerator.PLATFORMS.MICROSTACK_POCKETPC) { SampleApp = SourceCodeRepository.RemoveTag("//{{{BEGIN_WIN32}}}", "//{{{END_WIN32}}}", SampleApp); } else { SampleApp = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_WIN32}}}", "//{{{END_WIN32}}}", SampleApp); } #endregion if (Configuration.CPlusPlusWrapper) { SampleApp = SampleApp.Replace("//{{{CLASS_DEFINITIONS_DEVICE}}}", DeviceObjectGenerator.GetCPlusPlus_DerivedSampleClasses(devices)); SampleApp = SampleApp.Replace("//{{{CLASS_IMPLEMENTATIONS_DEVICE}}}", DeviceObjectGenerator.GetCPlusPlus_DerivedSampleClasses_Implementation(devices)); SampleApp = SampleApp.Replace("//{{{DERIVED_CLASS_INSERTION}}}", DeviceObjectGenerator.GetCPlusPlus_DerivedSampleClasses_Insertion(devices)); } SampleApp = SampleApp.Replace("{{{INITSTRING}}}", ""); SampleApp = SampleApp.Replace("//{{{DEVICE_INVOCATION_DISPATCH}}}", ""); SampleApp = SampleApp.Replace("//{{{INVOCATION_FP}}}", ""); SampleApp = SampleApp.Replace("//{{{MICROSTACK_VARIABLE}}}", ""); SampleApp = SampleApp.Replace("//{{{MicroStack_Include}}}", ""); SampleApp = SampleApp.Replace("//{{{CREATE_MICROSTACK}}}", ""); SampleApp = SampleApp.Replace("//{{{STATEVARIABLES_INITIAL_STATE}}}", ""); SampleApp = SampleApp.Replace("//{{{IPAddress_Changed}}}", ""); SampleApp = SampleApp.Replace("//{{{PresentationRequest}}}", ""); if (this.Configuration.InitThreadPoolInSampleApp) { SampleApp = SourceCodeRepository.RemoveTag("//{{{BEGIN_THREADPOOL}}}", "//{{{END_THREADPOOL}}}", SampleApp); SampleApp = SampleApp.Replace("!NUMTHREADPOOLTHREADS!", Configuration.ThreadPoolThreads_InSampleApp.ToString()); } else { SampleApp = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_THREADPOOL}}}", "//{{{END_THREADPOOL}}}", SampleApp); } if (Configuration.BareBonesSample) { SampleApp = SourceCodeRepository.RemoveTag("//{{{BEGIN_BAREBONES}}}", "//{{{END_BAREBONES}}}", SampleApp); } else { SampleApp = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_BAREBONES}}}", "//{{{END_BAREBONES}}}", SampleApp); } #region C or C++ if (Configuration.CPlusPlusWrapper) { SampleApp = SourceCodeRepository.RemoveAndClearTag("//{{{STANDARD_C_APP_BEGIN}}}", "//{{{STANDARD_C_APP_END}}}", SampleApp); SampleApp = SourceCodeRepository.RemoveTag("//{{{STANDARD_C++_APP_BEGIN}}}", "//{{{STANDARD_C++_APP_END}}}", SampleApp); } else { SampleApp = SourceCodeRepository.RemoveTag("//{{{STANDARD_C_APP_BEGIN}}}", "//{{{STANDARD_C_APP_END}}}", SampleApp); SampleApp = SourceCodeRepository.RemoveAndClearTag("//{{{STANDARD_C++_APP_BEGIN}}}", "//{{{STANDARD_C++_APP_END}}}", SampleApp); } #endregion #region Write to disk switch (Configuration.TargetPlatform) { case ServiceGenerator.PLATFORMS.MICROSTACK_POSIX: case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK1: case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK2: if (Configuration.CPlusPlusWrapper) { W = File.CreateText(outputDirectory.FullName + "\\Main.cpp"); SampleApp = SampleApp.Replace("Main.c", "Main.cpp"); } else { W = File.CreateText(outputDirectory.FullName + "\\Main.c"); } break; case ServiceGenerator.PLATFORMS.MICROSTACK_POCKETPC: W = File.CreateText(outputDirectory.FullName + "\\SampleProjectDlg.cpp"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_SYMBIANv9_1: W = File.CreateText(outputDirectory.FullName + "\\Sample.cpp"); break; default: W = null; break; } if (W != null) { W.Write(SampleApp); W.Close(); } #endregion #endregion #region Visual Studio Files and Posix Makefile #region Initialize Project and Makefile switch (Configuration.TargetPlatform) { case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK1: WS = SourceCodeRepository.Get_UPnPSample_vcproj().Replace("{{{WINSOCK}}}", "WINSOCK1"); WS = WS.Replace("{{{WINSOCK_LIB}}}", "WSock32.lib"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK2: WS = SourceCodeRepository.Get_UPnPSample_vcproj().Replace("{{{WINSOCK}}}", "WINSOCK2"); WS = WS.Replace("{{{WINSOCK_LIB}}}", "Psapi.lib ws2_32.lib Iphlpapi.lib"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POSIX: WS = SourceCodeRepository.Get_Makefile().Replace("{{{BUILD_NUMBER}}}", UseVersion); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POCKETPC: WS = SourceCodeRepository.Get_SampleProject_vcp(); break; case ServiceGenerator.PLATFORMS.MICROSTACK_SYMBIANv9_1: WS = SourceCodeRepository.Get_Generic("_MMP"); break; } #endregion if (WS != null) { #region Building Project and Makefile if (Configuration.GenerateThreadPoolLibrary) { WS = SourceCodeRepository.RemoveTag("//{{{BEGIN_THREADPOOL}}}", "//{{{END_THREADPOOL}}}", WS); } else { WS = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_THREADPOOL}}}", "//{{{END_THREADPOOL}}}", WS); } if (Configuration.CPlusPlusWrapper) { WS = SourceCodeRepository.RemoveTag("//{{{BEGIN_C++}}}", "//{{{END_C++}}}", WS); } else { WS = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_C++}}}", "//{{{END_C++}}}", WS); } WS = WS.Replace("ILib", Configuration.prefixlib); deviceOK = false; cpOK = false; foreach (UPnPDevice device in devices) { ServiceGenerator.Configuration DeviceConf = (ServiceGenerator.Configuration)device.User; switch (DeviceConf.ConfigType) { case ServiceGenerator.ConfigurationType.DEVICE: deviceOK = true; switch (Configuration.TargetPlatform) { case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK1: case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK2: WS = WS.Replace("{{{INCLUDE_C}}}", "{{{INCLUDE_C}}}" + "\r\n<File RelativePath=\"" + DeviceConf.Prefix + "MicroStack.c\"/>"); WS = WS.Replace("{{{INCLUDE_H}}}", "{{{INCLUDE_H}}}" + "\r\n<File RelativePath=\"" + DeviceConf.Prefix + "MicroStack.h\"/>"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POSIX: WS = WS.Replace("{{{O_FILES}}}", DeviceConf.Prefix + "MicroStack.o\\" + "\n{{{O_FILES}}}"); WS = WS.Replace("{{{H_FILES}}}", DeviceConf.Prefix + "MicroStack.h\\" + "\n{{{H_FILES}}}"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POCKETPC: WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "{{{BEGIN_MICROSTACK_DEFINTION}}}", "{{{END_MICROSTACK_DEFINTION}}}"); WS2 = WS2.Replace("{{CODEPREFIX}}", DeviceConf.Prefix); WS2 = WS2.Replace("{{LIBPREFIX}}", Configuration.prefixlib); WS2 = WS2.Replace("{{CODEPREFIX_CAPS}}", DeviceConf.Prefix.ToUpper()); WS2 = WS2.Replace("{{STACK}}", "MicroStack"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "{{{BEGIN_MICROSTACK_DEFINTION}}}", WS2); WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "{{{BEGIN_MICROSTACK_H}}}", "{{{END_MICROSTACK_H}}}"); WS2 = WS2.Replace("{{CODEPREFIX}}", DeviceConf.Prefix); WS2 = WS2.Replace("{{STACK}}", "MicroStack"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "{{{BEGIN_MICROSTACK_H}}}", WS2); WS = WS.Replace("{{{MICROSTACK_H}}}", "{{{MICROSTACK_H}}}\r\n\t\".\\" + DeviceConf.Prefix + "MicroStack.h\"\\"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_SYMBIANv9_1: WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "//{{{BeginSource}}}", "//{{{EndSource}}}"); WS2 = WS2.Replace("{{{SOURCE}}}", DeviceConf.Prefix + "MicroStack.c"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "//{{{BeginSource}}}", WS2); break; } break; case ServiceGenerator.ConfigurationType.CONTROLPOINT: cpOK = true; switch (Configuration.TargetPlatform) { case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK1: case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK2: WS = WS.Replace("{{{INCLUDE_C}}}", "{{{INCLUDE_C}}}" + "\r\n<File RelativePath=\"" + DeviceConf.Prefix + "ControlPoint.c\"/>"); WS = WS.Replace("{{{INCLUDE_H}}}", "{{{INCLUDE_H}}}" + "\r\n<File RelativePath=\"" + DeviceConf.Prefix + "ControlPoint.h\"/>"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POSIX: WS = WS.Replace("{{{O_FILES}}}", DeviceConf.Prefix + "ControlPoint.o\\" + "\n{{{O_FILES}}}"); WS = WS.Replace("{{{H_FILES}}}", DeviceConf.Prefix + "ControlPoint.h\\" + "\n{{{H_FILES}}}"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POCKETPC: WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "{{{BEGIN_MICROSTACK_DEFINTION}}}", "{{{END_MICROSTACK_DEFINTION}}}"); WS2 = WS2.Replace("{{CODEPREFIX}}", DeviceConf.Prefix); WS2 = WS2.Replace("{{LIBPREFIX}}", Configuration.prefixlib); WS2 = WS2.Replace("{{CODEPREFIX_CAPS}}", DeviceConf.Prefix.ToUpper()); WS2 = WS2.Replace("{{STACK}}", "ControlPoint"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "{{{BEGIN_MICROSTACK_DEFINTION}}}", WS2); WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "{{{BEGIN_MICROSTACK_H}}}", "{{{END_MICROSTACK_H}}}"); WS2 = WS2.Replace("{{CODEPREFIX}}", DeviceConf.Prefix); WS2 = WS2.Replace("{{STACK}}", "ControlPoint"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "{{{BEGIN_MICROSTACK_H}}}", WS2); WS = WS.Replace("{{{MICROSTACK_H}}}", "{{{MICROSTACK_H}}}\r\n\t\".\\" + DeviceConf.Prefix + "ControlPoint.h\"\\"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_SYMBIANv9_1: WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "//{{{BeginSource}}}", "//{{{EndSource}}}"); WS2 = WS2.Replace("{{{SOURCE}}}", DeviceConf.Prefix + "ControlPoint.c"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "//{{{BeginSource}}}", WS2); break; } break; } } if (cpOK) { // Insert CP related files into the project file switch (Configuration.TargetPlatform) { case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK1: case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK2: WS = WS.Replace("{{{INCLUDE_C}}}", "{{{INCLUDE_C}}}" + "\r\n<File RelativePath=\"" + Configuration.prefixlib + "SSDPClient.c\"/>"); WS = WS.Replace("{{{INCLUDE_H}}}", "{{{INCLUDE_H}}}" + "\r\n<File RelativePath=\"" + Configuration.prefixlib + "SSDPClient.h\"/>"); WS = WS.Replace("{{{INCLUDE_H}}}", "{{{INCLUDE_H}}}" + "\r\n<File RelativePath=\"UPnPControlPointStructs.h\"/>"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POSIX: WS = WS.Replace("{{{O_FILES}}}", Configuration.prefixlib + "SSDPClient.o\\" + "\n{{{O_FILES}}}"); WS = WS.Replace("{{{H_FILES}}}", Configuration.prefixlib + "SSDPClient.h\\" + "\n{{{H_FILES}}}"); break; case ServiceGenerator.PLATFORMS.MICROSTACK_POCKETPC: WS = WS.Replace("{{{MICROSTACK_H}}}", "{{{MICROSTACK_H}}}\r\n\t\".\\" + Configuration.prefixlib + "SSDPClient.h\"\\"); WS = WS.Replace("{{{MICROSTACK_H}}}", "{{{MICROSTACK_H}}}\r\n\t\".\\UPnPControlPointStructs.h\"\\"); WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "{{{BEGIN_MICROSTACK_H}}}", "{{{END_MICROSTACK_H}}}"); WS2 = WS2.Replace("{{CODEPREFIX}}", ""); WS2 = WS2.Replace("{{STACK}}", "UPnPControlPointStructs"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "{{{BEGIN_MICROSTACK_H}}}", WS2); WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "{{{BEGIN_MICROSTACK_H}}}", "{{{END_MICROSTACK_H}}}"); WS2 = WS2.Replace("{{CODEPREFIX}}", this.pc_methodLibPrefix); WS2 = WS2.Replace("{{STACK}}", "SSDPClient"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "{{{BEGIN_MICROSTACK_H}}}", WS2); WS = WS.Replace("{{LIBPREFIX}}", Configuration.prefixlib); WS = WS.Replace("{{LIBPREFIX_CAPS}}", Configuration.prefixlib.ToUpper()); WS = SourceCodeRepository.RemoveTag("{{{BEGIN_SSDPCLIENT}}}", "{{{END_SSDPCLIENT}}}", WS); break; case ServiceGenerator.PLATFORMS.MICROSTACK_SYMBIANv9_1: WS2 = SourceCodeRepository.GetTextBetweenTags(WS, "//{{{BeginSource}}}", "//{{{EndSource}}}"); WS2 = WS2.Replace("{{{SOURCE}}}", Configuration.prefixlib + "SSDPClient.c"); WS = SourceCodeRepository.InsertTextBeforeTag(WS, "//{{{BeginSource}}}", WS2); break; } } else { WS = SourceCodeRepository.RemoveAndClearTag("{{{BEGIN_SSDPCLIENT}}}", "{{{END_SSDPCLIENT}}}", WS); } WS = WS.Replace("{{{INCLUDE_C}}}", ""); WS = WS.Replace("{{{INCLUDE_H}}}", ""); WS = WS.Replace("{{{O_FILES}}}", ""); WS = WS.Replace("{{{H_FILES}}}", ""); WS = WS.Replace("{{{MICROSTACK_H}}}", ""); WS = SourceCodeRepository.RemoveAndClearTag("{{{BEGIN_MICROSTACK_DEFINTION}}}", "{{{END_MICROSTACK_DEFINTION}}}", WS); WS = SourceCodeRepository.RemoveAndClearTag("{{{BEGIN_MICROSTACK_H}}}", "{{{END_MICROSTACK_H}}}", WS); if (!Configuration.BareBonesSample) { WS = WS.Replace("<-- Additional Filters -->", ""); } #endregion #region Write various files to Disc switch (Configuration.TargetPlatform) { #region Visual Studio 2003 Solution/Project files case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK1: case ServiceGenerator.PLATFORMS.MICROSTACK_WINSOCK2: #region UPnPSample.vcproj if (Configuration.CPlusPlusWrapper) { WS = WS.Replace("Main.c", "Main.cpp"); } W = File.CreateText(outputDirectory.FullName + "\\UPnPSample.vcproj"); W.Write(WS); W.Close(); #endregion #region UPnPSample.sln W = File.CreateText(outputDirectory.FullName + "\\UPnPSample.sln"); W.Write(SourceCodeRepository.Get_UPnPSample_sln()); W.Close(); #endregion #region stdafx.h W = File.CreateText(outputDirectory.FullName + "\\stdafx.h"); W.Write(SourceCodeRepository.Get_Win32_stdafx_h()); W.Close(); #endregion #region stdafx.cpp W = File.CreateText(outputDirectory.FullName + "\\stdafx.cpp"); W.Write(SourceCodeRepository.Get_Win32_stdafx_cpp()); W.Close(); #endregion break; #endregion #region PocketPC 2003 Specific case ServiceGenerator.PLATFORMS.MICROSTACK_POCKETPC: #region SampleProject.vcp WS = WS.Replace("{{CODEPREFIX}}", this.pc_methodPrefix); WS = WS.Replace("{{CODEPREFIX_CAPS}}", this.pc_methodPrefix.ToUpper()); WS = WS.Replace("{{LIBPREFIX}}", this.pc_methodLibPrefix); WS = WS.Replace("{{LIBPREFIX_CAPS}}", this.pc_methodLibPrefix.ToUpper()); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\SampleProject.vcp"); W.Write(WS); W.Close(); #endregion #endregion #region SampleProjectDlg.h WS = SourceCodeRepository.Get_SampleProjectDlg_h(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\SampleProjectDlg.h"); W.Write(WS); W.Close(); #endregion #endregion #region SampleProject.cpp WS = SourceCodeRepository.Get_SampleProject_cpp(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\SampleProject.cpp"); W.Write(WS); W.Close(); #endregion #endregion #region SampleProject.h WS = SourceCodeRepository.Get_SampleProject_h(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\SampleProject.h"); W.Write(WS); W.Close(); #endregion #endregion #region newres.h WS = SourceCodeRepository.Get_newres_h(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\newres.h"); W.Write(WS); W.Close(); #endregion #endregion #region resource.h WS = SourceCodeRepository.Get_resource_h(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\resource.h"); W.Write(WS); W.Close(); #endregion #endregion #region SampleProject.rc WS = SourceCodeRepository.Get_SampleProject_rc(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\SampleProject.rc"); W.Write(WS); W.Close(); #endregion #endregion #region SampleProject.vcw WS = SourceCodeRepository.Get_SampleProject_vcw(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\SampleProject.vcw"); W.Write(WS); W.Close(); #endregion #endregion #region StdAfx.h WS = SourceCodeRepository.Get_StdAfx_h(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\StdAfx.h"); W.Write(WS); W.Close(); #endregion #endregion #region StdAfx.cpp WS = SourceCodeRepository.Get_StdAfx_cpp(); #region Write to disk W = File.CreateText(outputDirectory.FullName + "\\StdAfx.cpp"); W.Write(WS); W.Close(); #endregion #endregion #region SampleProject.ico #region Write to disk byte[] b = SourceCodeRepository.Get_SampleProject_ico(); FileStream F = File.Create(outputDirectory.FullName + "\\SampleProject.ico", b.Length); F.Write(b, 0, b.Length); F.Close(); #endregion #endregion break; #endregion #region Makefile case ServiceGenerator.PLATFORMS.MICROSTACK_POSIX: if (Configuration.CPlusPlusWrapper) { WS = WS.Replace("Main.c", "Main.cpp"); } W = File.CreateText(outputDirectory.FullName + "\\makefile"); W.Write(WS); W.Close(); break; #endregion #region Symbian MMP File case ServiceGenerator.PLATFORMS.MICROSTACK_SYMBIANv9_1: W = File.CreateText(outputDirectory.FullName + "\\Sample.mmp"); WS = SourceCodeRepository.RemoveAndClearTag("//{{{BeginSource}}}", "//{{{EndSource}}}", WS); W.Write(WS); W.Close(); break; #endregion } #endregion } #endregion } return (RetVal); }
public void generateButton_Click(object sender, System.EventArgs e) { DirectoryInfo outputDir = new DirectoryInfo(outputPathTextBox.Text); if (outputDir.Exists == false) { MessageBox.Show(this,"Output Path is invalid","Code Generator"); return; } string buttonText = generateButton.Text; generateButton.Text = "Generating Stack..."; generateButton.Enabled = false; if(UPnP1dot1Enabled.Checked==true) { device.ArchitectureVersion = "1.1"; } else { device.ArchitectureVersion = "1.0"; } if(platformComboBox.SelectedIndex==4) { // .net CPDotNetGenerator gen = new CPDotNetGenerator(classNameTextBox.Text); genOutputTextBox.Clear(); gen.VersionString = "Intel StackBuilder Build#" + Application.ProductVersion; gen.StartupPath = Application.StartupPath; gen.OnLogOutput += new CPDotNetGenerator.LogOutputHandler(Log); try { gen.Generate(device,outputDir,serviceNames); } catch { MessageBox.Show(this,"Error Generating Code","Code Generator"); } gen.OnLogOutput -= new CPDotNetGenerator.LogOutputHandler(Log); } else { CPEmbeddedCGenerator gen = new CPEmbeddedCGenerator(); LibraryGenerator libgen = new LibraryGenerator(); genOutputTextBox.Clear(); gen.EnableDefaultIPAddressMonitor = IPAddressMonitor.Checked; switch (platformComboBox.SelectedIndex) { case 0: gen.Platform = CPEmbeddedCGenerator.PLATFORMS.POSIX; gen.SubTarget = CPEmbeddedCGenerator.SUBTARGETS.NONE; libgen.Platform = LibraryGenerator.PLATFORMS.POSIX; libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE; break; case 1: gen.Platform = CPEmbeddedCGenerator.PLATFORMS.WINDOWS; gen.SubTarget = CPEmbeddedCGenerator.SUBTARGETS.NONE; gen.WinSock = 1; libgen.Platform = LibraryGenerator.PLATFORMS.WINDOWS; libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE; libgen.WinSock = 1; break; case 2: gen.Platform = CPEmbeddedCGenerator.PLATFORMS.WINDOWS; gen.SubTarget = CPEmbeddedCGenerator.SUBTARGETS.NONE; gen.WinSock = 2; libgen.Platform = LibraryGenerator.PLATFORMS.WINDOWS; libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE; libgen.WinSock = 2; break; case 3: gen.Platform = CPEmbeddedCGenerator.PLATFORMS.WINDOWS; gen.SubTarget = CPEmbeddedCGenerator.SUBTARGETS.PPC2003; gen.WinSock = 1; libgen.Platform = LibraryGenerator.PLATFORMS.WINDOWS; libgen.SubTarget = LibraryGenerator.SUBTARGETS.PPC2003; libgen.WinSock = 1; break; case 4: gen.Platform = CPEmbeddedCGenerator.PLATFORMS.POSIX; gen.SubTarget = CPEmbeddedCGenerator.SUBTARGETS.NUCLEUS; gen.WinSock = 1; libgen.Platform = LibraryGenerator.PLATFORMS.POSIX; libgen.SubTarget = LibraryGenerator.SUBTARGETS.NUCLEUS; libgen.WinSock = 1; break; } switch (languageComboBox.SelectedIndex) { case 0: gen.Language = CPEmbeddedCGenerator.LANGUAGES.C; libgen.Language = LibraryGenerator.LANGUAGES.C; break; case 1: gen.Language = CPEmbeddedCGenerator.LANGUAGES.CPP; libgen.Language = LibraryGenerator.LANGUAGES.CPP; break; } switch (newLineComboBox.SelectedIndex) { case 0: gen.CodeNewLine = "\r\n"; break; case 1: gen.CodeNewLine = "\n"; break; } switch (callConventionComboBox.SelectedIndex) { case 0: gen.CallingConvention = ""; break; case 1: gen.CallingConvention = "_stdcall "; break; case 2: gen.CallingConvention = "_fastcall "; break; } switch (indentComboBox.SelectedIndex) { case 0: gen.CodeTab = "\t"; break; case 1: gen.CodeTab = " "; break; case 2: gen.CodeTab = " "; break; case 3: gen.CodeTab = " "; break; case 4: gen.CodeTab = " "; break; case 5: gen.CodeTab = " "; break; case 6: gen.CodeTab = " "; break; } gen.CallPrefix = prefixTextBox.Text; gen.CallLibPrefix = libPrefixTextBox.Text; gen.Settings = Settings; gen.FragResponseActions = FragResponseActions; gen.EscapeActions = EscapeActions; gen.VersionString = "Intel DeviceBuilder Build#" + Application.ProductVersion; gen.ClassName = classNameTextBox.Text; gen.UseVersion = Application.ProductVersion.Substring(0,Application.ProductVersion.LastIndexOf(".")); gen.BasicHTTP = !(HTTP.Checked); libgen.CodeNewLine = gen.CodeNewLine; libgen.CallingConvention = gen.CallingConvention; libgen.CodeTab = gen.CodeTab; libgen.CodeNewLine = gen.CodeNewLine; libgen.CallPrefix = libPrefixTextBox.Text; libgen.VersionString = gen.VersionString; libgen.ClassName = gen.ClassName; foreach(System.Data.DataRow r in dataSet1.Tables[0].Rows) { gen.CustomTagList.Add(new object[2]{(string)r.ItemArray[0],(string)r.ItemArray[1]}); } // Setup License string license = licenseTextBox.Text; license = license.Replace("<AUTHOR>","Intel Corporation, Intel Device Builder"); license = license.Replace("<REVISION>","#" + Application.ProductVersion); license = license.Replace("<DATE>",DateTime.Now.ToLongDateString()); gen.License = license; libgen.License = license; gen.OnLogOutput += new CPEmbeddedCGenerator.LogOutputHandler(Log); libgen.OnLogOutput += new LibraryGenerator.LogOutputHandler(Log); try { SourceCodeRepository.Generate_UPnPControlPointStructs(libPrefixTextBox.Text,outputDir); SourceCodeRepository.Generate_Parsers(this.libPrefixTextBox.Text,outputDir); SourceCodeRepository.Generate_SSDPClient(this.libPrefixTextBox.Text,outputDir,UPnP1dot1Enabled.Checked); SourceCodeRepository.Generate_AsyncSocket(this.libPrefixTextBox.Text,outputDir); SourceCodeRepository.Generate_AsyncServerSocket(this.libPrefixTextBox.Text,outputDir); SourceCodeRepository.Generate_WebClient(this.libPrefixTextBox.Text,outputDir,!HTTP.Checked); SourceCodeRepository.Generate_WebServer(this.libPrefixTextBox.Text,outputDir,!HTTP.Checked); gen.Generate(device,outputDir,serviceNames,!(bool)gen.Settings["SupressSample"]); } catch(Exception ddd) { MessageBox.Show(this,"Error Generating Code","Code Generator"); } libgen.OnLogOutput -= new LibraryGenerator.LogOutputHandler(Log); gen.OnLogOutput -= new CPEmbeddedCGenerator.LogOutputHandler(Log); } generateButton.Enabled = true; generateButton.Text = buttonText; }