CnvUtfConverter::ConverToUnicodeFormUtf8(src8, dest16);
CnvUtfConverter::ConverFromUnicodeToUtf8(dest8, src16);

NatPixnet 發表在 痞客邦 留言(0) 人氣()

静态库文件也称为“文档文件”,它是一些.o文件的集合。在Linux(Unix)中使用工具“ar”对它进行维护管理。它所包含的成员(member)是若干.o文件。
1      库成员作为目标
一个静态库通常由多个.o文件组成。这些成员(.o文件)可独立的被作为一个规则的目标,库成员作为目标时需要按照如下的格式来书写:

NatPixnet 發表在 痞客邦 留言(0) 人氣()



copy from: https://blog.sina.com.cn/s/blog_5df7dcaf0100be6w.html~type=v5_one&label=rela_nextarticle
 
从前,一个叫Brad Cox的人觉得是时候让编程更模块化一些.当时C语言是非常流行和强大的语言,Smalltalk 是一个优雅的面向对象语言.所以,基于C,Brad Cox增加了类Smalltalk的类和消息发送机制, Objective-C语言就诞生了.

NatPixnet 發表在 痞客邦 留言(0) 人氣()


control-F: 向右一个字符(forward)
control-B: 向左一个字符(backward)

NatPixnet 發表在 痞客邦 留言(0) 人氣()


 
copy from : https://blog.sina.com.cn/s/blog_5df7dcaf0100be6f.html~type=v5_one&label=rela_nextarticle 
          

NatPixnet 發表在 痞客邦 留言(0) 人氣()

1.png
 
第一章:什么是cocoa
1- 一点历史
          让我们从一个有意思的故事开始我们的cocoa旅程吧.很久前(我还没出生呢)有两个叫Steve的天才创建了一个公司,名为苹果电脑,这家公司成长的非常快,所以他们聘请了一个叫John Sculley的人来担任他们公司的CEO. 没想到的是,在一些矛盾冲突后,John Sculley居然把其中一个Steve的赶出了苹果公司,这个Steve就是现在大名顶顶的Steve Jobs. Jobs在离开苹果后组建了一个新的公司 Next Computer

NatPixnet 發表在 痞客邦 留言(0) 人氣()


It is often necessary to mix Open C with Active Objects. In particular, user interfaces are normally done with Active Objects. But if you want to call a blocking Open C function, such as the network communications functions, then you are faced with a problem. The blocking call will freeze your user interface until the call returns. If there is a non-blocking version of the call you could use a CTimer to repeatadly poll the function. But it is not battery efficient to have the periodic CPU activity involved in polling.
So you must turn to threads.
Okay.... here's pseudo code for a wrapper class around blocking calls named do_blocking_read_call and do_blocking_write_call. CMyCaller could be declared as a subclass of CBase.
The general idea is that the blocking calls are made from a new thread. The thread initializes then goes into a RSemapore::Wait. The main thread sets a command variable iCallerState and then calls RSemaphore::Signal to trigger the thread to execute the command. The two versions of RThread::Rendezvous are used together to coordinate with an Active Object.
After each Signal() the thread returns to the Wait state until the next Signal is given. A single thread with a repeating loop is used instead of creating and deleting a new thread each time.
class CMyCaller : public CBase
{
public:
// usual NewL construction stuff omitted
void ConstructL();
void DoCallAsynch(TRequestStatus& aStatus)
public:
void CallerThreadFn();
private:
RSemaphore iRequestSignal;
RThread iCallerThread;
TInt iCallerState;
}
The ConstructL function launches the new thread. The thread initializes, uses Rendezvous(TInt) to release User::WaitForRequest, and then Waits for a Signal.
void CMyCaller::ConstructL()
{
TRequestStatus status;
iRequestSignal.CreateLocal(0,EOwnerProcess); // 0=wait for first Signal()
iCallerThread.Create(_L("FN_Caller"), caller_thread_fn, stackSize, minHeap, maxHeap, this, EOwnerProcess);
 
iCallerState = ECallerInitializing;
iCallerThread.Rendezvous(status); // request that status get signaled
iCallerThread.Resume();
User::WaitForRequest(status);
// here you could check status for initialization failure.
}
The thread function(s).
TInt caller_thread_fn(TAny *aAddrSelf)
{
CMyCaller* self = (CMyCaller *)aAddrSelf;
self->CallerThreadFn();
return 0; // the docs don't say whether this value has any meaning
}
 
void CMyCaller::CallerThreadFn()
{
// NOTE: This code runs in its own thread with a different heap.
int ret;
TBuf8<8> port;
port.Num(iPort);
ret = init_server();
 
if (ret <0)
{
iCallerState = EInitializingFailed;
RThread::Rendezvous(KErrFailed);
return;
}
else {
iCallerState = ECallerReader;
RThread::Rendezvous(KErrNone);
}
FOREVER {
int success;
iCallerState = ECallerReady;
iRequestSignal.Wait();
 
switch (iCallerState) {
case ECallingReadFunction:
success = do_blocking_read_call(iSharedBuffer);
break;
case ECallingWriteFunction:
success = do_blocking_write_call(iSharedBuffer);
break;
}
 
if (success) RThread().Rendezvous (KErrNone);
else RThread().Rendezvous (KErrGeneral);
}
}
Now add an asynchronous function to be called from your Active Object.
// Call from an active object
void CMyCaller::DoCallAsynch(TRequestStatus& aStatus)
{
// Rendezvous(TRequestStatus) requests that the AO's RunL
// get called later when the thread calls Rendezvous(TInt).
iCallerThread.Rendezvous(aStatus);
 
// Tell the thread function which operation do execute
//
iCallerState = ECallingReadFunction;
 
// Release the thread from its Wait call.
iRequestSignal.Signal();
}
Note that because CallerThreadFn runs in a different thread, it does not manipulate any Symbian objects from another thread. It also is important to use the version of RThread::Create that will create its own heap. Otherwise you may have multiple threads manipulating the same heap - since the heap is not thread safe it can become corrupted. Don't allocate a heap object and then pass its ownership to another thread because it may not be safe if it later gets deleted by a thread with a different heap.
In this pattern all data is passed by copying bytes into a shared buffer.
Note: It's not documented that every RThread must be given a unique name in the Create function.

NatPixnet 發表在 痞客邦 留言(0) 人氣()

1.Shared Memory

A crude and straightforward way to exchange information between threads is to use shared memory.
Thread entry point function takes one parameter, TAny *aPtr. This pointer can be used for any purpose. Often it is used to pass a pointer to a data structure or class instance that contains the information shared between threads. Because threads within a same process share the same memory address space, the data pointed to by that pointer can be used normally after casting it to the proper type, except that access to this data must be synchronized.
In Symbian OS 7.0s and earlier versions, the pointer given to the thread function can be changed afterwards by calling SetInitialParameter(TAny* aPtr) on the suspended thread. Platform security changes removed this function, so in the OS versions 7.0s onwards, the thread has to be created with function TInt RThread::Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, RAllocator *aHeap, TAny *aPtr, TOwnerType aType=EOwnerProcess). If aHeap is NULL, then the new thread uses the heap of the creating thread. If heap is not shared by giving it as a parameter, USER 42 panic may appear when trying to use the memory of another thread's heap.
Sharing the heap does not mean that the R-class sessions are shared between threads. This can be achieved, for example in the case of RFs, by calling the function RSessionBase::ShareAuto().

2.Client/Server API
A client makes use of services provided by a server. The server receives request messages from its clients and handles them, either synchronously or asynchronously. Data is passed from the client to the server in the request message itself or by passing a pointer to a descriptor in the client address space, which the server accesses using kernel-mediated data transfer. On Symbian OS, servers are typically used to manage shared access to system resources and services. The use of a server is efficient since it can service multiple client sessions and can be accessed concurrently by clients running in separate threads.
Symbian OS offers a server/session based API that enables one thread to act as a server and to provide services for other threads and processes. This API also offers a convenient way to handle message passing, synchronization, and data transfer.
Related: Client-Server Framework

Inter-Process Data Transfer
Inter-Process Data Transfer
 
 

3.Thread-Local Storage (TLS)
On EKA1, Symbian OS doesn’t allow Writeable Static Data (WSD for short) in DLLs. There is, though, one 32-bit word allocated per thread per DLL. This word can be used as a pointer to the data structure or class instance. The allocation and de-allocation of this structure can be done, for example, in a DLL entry point function E32Dll.
The TLS slot can be used directly if you have only one machine word of data to store. For extensibility, it is more likely that you’ll use it to storea pointer to a struct or simple T Class which encapsulates all the data you would otherwise have declared as static.
Thread-local storage is usually initialized when the DLL is attached to a thread within the DLL entry point, E32Dll().
The Dll::SetTls(TAny *aPtr) function sets the pointer to thread-local storage. The Dll::Tls() function returns a pointer to thread-local storage. The data pointed to by that pointer can be used normally.
On EKA2, WSD can be used see Writeable Static Data for more details.

4.Exception Handling
In Symbian OS, there are lots of events that can raise exceptions on other threads. These exceptions are not equivalent to ANSI C++ exceptions.
On EKA1, the RThread API supports thread exception management. On the more secure EKA2 platform, this has moved into class User and applies only to the current thread.
The following functions are involved in exception handling:
 
RThread::ExceptionHandler()
RThread::SetExceptionHandler()
RThread::ModifyExceptionMask()
RThread::RaiseException()
RThread::IsExceptionHandled()
 
TInt SetExceptionHandler(TExceptionHandler* aHandler, TUint32 aMask);
SetExceptionHandler() allows you to define an exception handler function for the thread for which the handle is valid.
 

5.Publish & Subscribe
Publish & Subscribe is an inter-process communication mechanism introduced in Symbian OS v8.0a.
This mechanism includes three basic entities: properties,publishers and subscribers.
Properties are single global variables that are identified by a standard Symbian OS UID that defines the property category, and another integer that defines the property sub-key.
Publishers are threads that update a property.
Subscribers are threads that listen to changes to a property.
 

6.Message Queues
Message queues are used to send messages to queue without knowing the identity or existence of the recipient. Any process (in the case of global queues) or any thread within the same process (in the case of local queues) may read these messages.
For more information, refer to Message Queues

NatPixnet 發表在 痞客邦 留言(0) 人氣()

 
1. Login with root account
 
2. Edit /etc/samba/smb.conf file

NatPixnet 發表在 痞客邦 留言(0) 人氣()

 
Overview

This code snippet demonstrates how to use CEikLabel control, how to set font, how to set font color and how to wrap text in label.
 

MMP File.
Following library need to be added in mmp file.
LIBRARY eikcoctl.lib gdi.lib
 

Header File.
Add following line to your header file.
CEikLabel* iLabel;
CArrayFix<TPtrC>* iTextArray; //for creating multiline label.
HBufC* iMultiLineText; // //for creating multiline label.
 

Source File.
Add following header file in your source file.
#include <eiklabel.h>
#include <aknutils.h>
#include <gulcolor.h>
#include <GDI.H>
Add following source code in ConstructL() method.
const CFont* font = CCoeEnv::Static()->NormalFont();

iTextArray = new CArrayFixFlat<TPtrC>(1);
iMultiLineText = HBufC::NewL(0);

iLabel = new (ELeave) CEikLabel;
iLabel->SetContainerWindowL( *this );
//Set your custom font here.
iLabel->SetFont(font);

//wrapping text to set in label.
TBuf<100> buffer;
buffer.Copy(_L("Testing long label in symbian OS c++."));
iTextArray->Reset();
TInt screenWidth = 240 ; // set width as per your requirement.
AknTextUtils::WrapToArrayL(buffer, screenWidth,*font, *iTextArray);
TInt Height = 0; //to set height of label.[[Category:Symbian C++]]
for (TInt i = 0; i < iTextArray->Count(); i++)
{
TInt length = iTextArray->At(i).Length() + 1;
iMultiLineText = iMultiLineText->ReAllocL(iMultiLineText->Length() + length);
iMultiLineText->Des().Append(iTextArray->At(i));
iMultiLineText->Des().Append(_L("\n"));
Height += font->HeightInPixels() + font->AscentInPixels()/2;
}

iLabel->SetTextL(iMultiLineText->Des());

// setting font color to red.
iLabel->OverrideColorL( EColorLabelTextEmphasis, KRgbRed );
iLabel->SetEmphasis( CEikLabel::EPartialEmphasis );

//set position of label.
iLabel->SetPosition(TPoint(0, 20));
//set size of label.
iLabel->SetSize(TSize(screenWidth,Height));
Add the following code in the destructor to delete all used variables.
delete iLabel;
delete iTextArray;
delete iMultiLineText;

NatPixnet 發表在 痞客邦 留言(0) 人氣()

 
编辑相关
* Ctrl+ ↓ Ctrl+↑ 在编辑区上下滚动(滚动滑块)
* Ctrl+ ← Ctrl + → 向前向后移动一个单词
* Ctrl+ Shift + ↓ Ctrl+ Shift + ↑ 向上向下移動一個段落(可以方便的在function中滚動,查到自己所屬的function)
* Ctrl+G 搜索工作区中的声明
* Ctrl+ Shift +G 搜索所有引用
* Ctrl+ Shift +S 保存所有文档
* Ctrl+F 查找替换
* Ctrl + J 增量查找(根据动态键盘输入进行动态匹配)
* Ctrl + k 查找替换下一个
* Ctrl + L 转到指定的行号
* Ctrl+ Shift + F4 关闭所有编辑窗口
* Ctrl + SHIFT + P 匹配对应的括号
* CTRL+SHIFT+X 将选中的小写转换为大写
* CTRL+SHIFT+Y 将选中的大写转换为小写
* Ctrl+M 将当前窗口在最小化和最大化之间切换
* Ctrl+Q 定义最后编辑的地方
* Ctrl+O 快速顯示 OutLine,要跳到某function時很好用!類似function list
* Ctrl+K 找下一個(find next or +shift = find pre)
* Ctrl+E 快速显示当前Editer的下拉列表
* Ctrl+` 在c/c++中非常有用的功能 打開相關的.cpp及.h檔
* Ctrl+D 删除当前行
* Ctrl+Alt+↓ 复制当前行到下一行(复制增加)
* Ctrl+Alt+↑ 复制当前行到上一行(复制增加)
* Alt+↓/↑ 当前行和下/上面一行交换位置

NatPixnet 發表在 痞客邦 留言(0) 人氣()

 
RSocketServ gSocketServer;
RConnection gConnection;
RSocket fd;

NatPixnet 發表在 痞客邦 留言(0) 人氣()

1 2
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。