|
17 | 17 | #include <AknUtils.h> |
18 | 18 | #include <eikstart.h> |
19 | 19 | #include <aknmessagequerydialog.h> |
| 20 | +#include <baclipb.h> |
| 21 | +#include <s32ucmp.h> |
20 | 22 | #include <classicube.rsg> |
21 | 23 |
|
22 | 24 | extern "C" { |
@@ -801,6 +803,63 @@ static void ShowDialogL(const char* title, const char* msg) { |
801 | 803 | dialog->RunLD(); |
802 | 804 | } |
803 | 805 |
|
| 806 | +static void GetClipboardL(cc_string* value) { |
| 807 | + TUid uid = {268450333}; // KClipboardUidTypePlainText |
| 808 | + |
| 809 | + CClipboard* cb = CClipboard::NewForReadingLC(CCoeEnv::Static()->FsSession()); |
| 810 | + TStreamId stid = cb->StreamDictionary().At(uid); |
| 811 | + if (stid != KNullStreamId) { |
| 812 | + RStoreReadStream stream; |
| 813 | + stream.OpenLC(cb->Store(), stid); |
| 814 | + const TInt32 size = stream.ReadInt32L(); |
| 815 | + HBufC* buf = HBufC::NewLC(size); |
| 816 | + buf->Des().SetLength(size); |
| 817 | + |
| 818 | + TUnicodeExpander e; |
| 819 | + TMemoryUnicodeSink sink(&buf->Des()[0]); |
| 820 | + e.ExpandL(sink, stream, size); |
| 821 | + |
| 822 | + String_AppendUtf16(value, buf->Ptr(), buf->Length() * 2); |
| 823 | + |
| 824 | + stream.Close(); |
| 825 | + CleanupStack::Pop(); |
| 826 | + CleanupStack::PopAndDestroy(buf); |
| 827 | + } |
| 828 | + CleanupStack::PopAndDestroy(cb); |
| 829 | +} |
| 830 | + |
| 831 | +static void SetClipboardL(const cc_string* value) { |
| 832 | + TUid uid = {268450333}; // KClipboardUidTypePlainText |
| 833 | + |
| 834 | + HBufC* buf = HBufC::NewLC(value->length + 1); |
| 835 | + TPtr16 des = buf->Des(); |
| 836 | + ConvertToUnicode(des, value); |
| 837 | + |
| 838 | + CClipboard* cb = CClipboard::NewForWritingLC(CCoeEnv::Static()->FsSession()); |
| 839 | + |
| 840 | + RStoreWriteStream stream; |
| 841 | + TStreamId stid = stream.CreateLC(cb->Store()); |
| 842 | + stream.WriteInt32L(buf->Length()); |
| 843 | + |
| 844 | + TUnicodeCompressor c; |
| 845 | + TMemoryUnicodeSource source(buf->Ptr()); |
| 846 | + TInt bytes(0); |
| 847 | + TInt words(0); |
| 848 | + c.CompressL(stream, source, KMaxTInt, buf->Length(), &bytes, &words); |
| 849 | + |
| 850 | + stream.WriteInt8L(0); |
| 851 | + |
| 852 | + stream.CommitL(); |
| 853 | + cb->StreamDictionary().AssignL(uid, stid); |
| 854 | + cb->CommitL(); |
| 855 | + |
| 856 | + stream.Close(); |
| 857 | + CleanupStack::PopAndDestroy(); |
| 858 | + CleanupStack::PopAndDestroy(cb); |
| 859 | + |
| 860 | + CleanupStack::PopAndDestroy(buf); |
| 861 | +} |
| 862 | + |
804 | 863 | // Window implementation |
805 | 864 |
|
806 | 865 | void Window_PreInit(void) { |
@@ -835,11 +894,11 @@ void Window_Destroy(void) { } |
835 | 894 | void Window_SetTitle(const cc_string* title) { } |
836 | 895 |
|
837 | 896 | void Clipboard_GetText(cc_string* value) { |
838 | | - // TODO |
| 897 | + TRAP_IGNORE(GetClipboardL(value)); |
839 | 898 | } |
840 | 899 |
|
841 | 900 | void Clipboard_SetText(const cc_string* value) { |
842 | | - // TODO |
| 901 | + TRAP_IGNORE(SetClipboardL(value)); |
843 | 902 | } |
844 | 903 |
|
845 | 904 | int Window_GetWindowState(void) { |
|
0 commit comments