-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatroskaPagesTag.cpp
3534 lines (3258 loc) · 138 KB
/
MatroskaPagesTag.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Part of The TCMP Matroska CDL, and Matroska Shell Extension
*
* MatroskaPagesTag.cpp
*
* Copyright (C) Jory Stone - June 2003
* Copyright (C) John Cannon - 2003
*
* CDL API Copyright (C) Blacksun & Toff - 2003
*
* The TCMP Matroska CDL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* The TCMP Matroska CDL 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with The TCMP Matroska CDL; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/*!
\file MatroskaPagesTag.cpp
\version \$Id: MatroskaPagesTag.cpp,v 1.13 2004/03/20 05:08:30 jcsston Exp $
\brief This is all the GUI code for the CDL and Shell Ext
\author Jory Stone <jcsston @ toughguy.net>
*/
#include "MatroskaPages.h"
using namespace LIBEBML_NAMESPACE;
using namespace LIBMATROSKA_NAMESPACE;
using namespace MatroskaUtilsNamespace;
extern long g_MyBuildNumber;
BOOL CALLBACK MediaPropProc_AddTag(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
CRASH_PROTECT_START;
//Get the dialog data
MatroskaPages *pageData = (MatroskaPages *)GetWindowLong(hwndDlg, DWL_USER);
switch(uMsg) {
case WM_INITDIALOG:
{
SetWindowText(hwndDlg, _W("Add a new Tag"));
SetDlgItemText(hwndDlg, IDC_STATIC_ADD_TAG_1, _W("Choose the type of tag to add"));
SetDlgItemText(hwndDlg, IDC_BUTTON_ADDTAG_OK, _W("OK"));
SetDlgItemText(hwndDlg, IDC_BUTTON_ADDTAG_CANCEL, _W("Cancel"));
uint32 item = 1;
char *tag_item_name = NULL;
//Loop until we reach the end of the tag name list
for (item = 1; item <= 44; item++)
{
//Get the next tag name
tag_item_name = MatroskaTagInfo::GetTagListStr(item);
if (tag_item_name != NULL)
{
//Add the current tag name to the list
SendDlgItemMessageA(hwndDlg, IDC_LIST_ADDTAG, LB_ADDSTRING, 0, (LPARAM)tag_item_name);
}
}
return TRUE;
break;
}
case WM_CLOSE:
{
EndDialog(hwndDlg, IDCANCEL);
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{ /* Find which control the message applies to */
case IDC_BUTTON_ADDTAG_OK:
{
//Add the selected tag :P
int nItem = 0;
//Get the selected tag type
nItem = SendDlgItemMessage(hwndDlg, IDC_LIST_ADDTAG, LB_GETCURSEL, 0, 0);
char *field_txt = new char[SendDlgItemMessageA(hwndDlg, IDC_LIST_ADDTAG, LB_GETTEXTLEN, nItem, 0)+1];
SendDlgItemMessageA(hwndDlg, IDC_LIST_ADDTAG, LB_GETTEXT, (nItem), (LPARAM)field_txt);
uint32 tag_type = 0;
tag_type = MatroskaTagInfo::GetTagListUInt(field_txt);
MatroskaTagInfo *current_tag = GetSelectedTagEntry(pageData->g_hTagDialog);
if (current_tag != NULL) {
switch (tag_type) {
case 1: //"MultiComment"
{
MatroskaTagMultiCommentItem *added_multi_comment_item = new MatroskaTagMultiCommentItem;
added_multi_comment_item->Language = "eng"; //Default Langauge
added_multi_comment_item->Comments = L"A new MultiComment tag";
//Once again we have to check if the tag already exists
if (current_tag->Tag_MultiComments != NULL) {
current_tag->Tag_MultiComments->AddItem(added_multi_comment_item);
}else {
//Nope we need to create a new one
MatroskaTagMultiComment *new_multi_list = new MatroskaTagMultiComment;
//Attach this new Multi tag list
current_tag->Tag_MultiComments = new_multi_list;
//Append our new item
current_tag->Tag_MultiComments->AddItem(added_multi_comment_item);
}
break;
}
case 2: //"MultiCommercial"
{
MatroskaTagMultiCommercialItem *added_multi_commercial_item = new MatroskaTagMultiCommercialItem;
added_multi_commercial_item->Type = KaxTagMultiCommercialType_FilePurchase; //Default Type
added_multi_commercial_item->PriceAmount = 1.00; //Is 1 unit enough :D
//Once again we have to check if the tag already exists
if (current_tag->Tag_MultiCommercials != NULL) {
current_tag->Tag_MultiCommercials->AddItem(added_multi_commercial_item);
}else {
//Nope we need to create a new one
MatroskaTagMultiCommercial *new_multi_list = new MatroskaTagMultiCommercial;
//Attach this new Multi tag list
current_tag->Tag_MultiCommercials = new_multi_list;
//Append our new item
current_tag->Tag_MultiCommercials->AddItem(added_multi_commercial_item);
}
break;
}
case 3: //"MultiDate"
{
MatroskaTagMultiDateItem *added_multi_item = new MatroskaTagMultiDateItem;
//Set the intial values to be right now
added_multi_item->Type = KaxTagMultiDateType_TaggingDate;
time_t ltime = 0;
time(<ime);
added_multi_item->DateBegin = ltime;
added_multi_item->DateEnd = ltime;
//Once again we have to check if the tag already exists
if (current_tag->Tag_MultiDates != NULL) {
current_tag->Tag_MultiDates->AddItem(added_multi_item);
}else {
//Nope we need to create a new one
MatroskaTagMultiDate *new_multi_list = new MatroskaTagMultiDate;
//Attach this new Multi tag list
current_tag->Tag_MultiDates = new_multi_list;
//Append our new item
current_tag->Tag_MultiDates->AddItem(added_multi_item);
}
break;
}
case 4: //"MultiEntity"
{
MatroskaTagMultiEntityItem *added_multi_entity_item = new MatroskaTagMultiEntityItem;
added_multi_entity_item->Type = KaxTagMultiEntitiesType_EditedBy; //Default Type
added_multi_entity_item->Name = L"The TCMP Matroska plugin";
//Once again we have to check if the tag already exists
if (current_tag->Tag_MultiEntities != NULL) {
current_tag->Tag_MultiEntities->AddItem(added_multi_entity_item);
}else {
//Nope we need to create a new one
MatroskaTagMultiEntity *new_multi_list = new MatroskaTagMultiEntity;
//Attach this new Multi tag list
current_tag->Tag_MultiEntities = new_multi_list;
//Append our new item
current_tag->Tag_MultiEntities->AddItem(added_multi_entity_item);
}
break;
}
case 5: //"MultiIdentifier"
{
MatroskaTagMultiIdentifierItem *added_multi_identifier_item = new MatroskaTagMultiIdentifierItem;
added_multi_identifier_item->Type = KaxTagMultiIdentifierType_UniqueFileIdentifier; //Default Type
added_multi_identifier_item->StringData = L"Blank";
//Once again we have to check if the tag already exists
if (current_tag->Tag_MultiIdentifiers != NULL) {
current_tag->Tag_MultiIdentifiers->AddItem(added_multi_identifier_item);
}else {
//Nope we need to create a new one
MatroskaTagMultiIdentifier *new_multi_list = new MatroskaTagMultiIdentifier;
//Attach this new Multi tag list
current_tag->Tag_MultiIdentifiers = new_multi_list;
//Append our new item
current_tag->Tag_MultiIdentifiers->AddItem(added_multi_identifier_item);
}
break;
}
case 6: //"MultiLegal"
{
MatroskaTagMultiLegalItem *added_multi_legal_item = new MatroskaTagMultiLegalItem;
added_multi_legal_item->Type = KaxTagMultiLegalType_Copyright; //Default Type
added_multi_legal_item->URL = "http://";
//Once again we have to check if the tag already exists
if (current_tag->Tag_MultiLegals != NULL) {
current_tag->Tag_MultiLegals->AddItem(added_multi_legal_item);
}else {
//Nope we need to create a new one
MatroskaTagMultiLegal *new_multi_list = new MatroskaTagMultiLegal;
//Attach this new Multi tag list
current_tag->Tag_MultiLegals = new_multi_list;
//Append our new item
current_tag->Tag_MultiLegals->AddItem(added_multi_legal_item);
}
break;
}
case 7: //"MultiTitle"
{
MatroskaTagMultiTitleItem *added_multi_title_item = new MatroskaTagMultiTitleItem;
added_multi_title_item->Type = KaxTagMultiTitleType_TrackTitle; //Default Type
added_multi_title_item->Name = L"Blank";
//Once again we have to check if the tag already exists
if (current_tag->Tag_MultiTitles != NULL) {
current_tag->Tag_MultiTitles->AddItem(added_multi_title_item);
}else {
//Nope we need to create a new one
MatroskaTagMultiTitle *new_multi_list = new MatroskaTagMultiTitle;
//Attach this new Multi tag list
current_tag->Tag_MultiTitles = new_multi_list;
//Append our new item
current_tag->Tag_MultiTitles->AddItem(added_multi_title_item);
}
break;
}
case 9: //"Archival Location"
{
if (!(current_tag->Tag_ArchivalLocation.length() > 0))
{
current_tag->Tag_ArchivalLocation = L"Blank";
}
break;
}
case 10: //"Audio Gain"
{
if (!(current_tag->Tag_AudioGain = 0))
{
current_tag->Tag_AudioGain = 1;
}
break;
}
case 11: //"Audio Genre"
{
if (!(current_tag->Tag_AudioGenre.length() > 0))
{
current_tag->Tag_AudioGenre = "Blank";
}
break;
}
case 12: //"Audio Peak"
{
if (current_tag->Tag_AudioPeak == 0)
{
current_tag->Tag_AudioPeak = 1;
}
break;
}
case 13: //"Audio Secondary Genre"
{
if (!(current_tag->Tag_AudioSecondaryGenre.length() > 0))
{
current_tag->Tag_AudioSecondaryGenre = "Blank";
}
break;
}
case 14: //"Bibliography"
{
if (!(current_tag->Tag_Bibliography.length() > 0))
{
current_tag->Tag_Bibliography = L"Blank";
}
break;
}
case 15: //"BPM"
{
if (current_tag->Tag_BPM == 0)
{
current_tag->Tag_BPM = 1;
}
break;
}
case 16: //"Capture DPI"
{
if (current_tag->Tag_CaptureDPI == 0)
{
current_tag->Tag_CaptureDPI = 1;
}
break;
}
case 17: //"Capture Palette Setting"
{
if (current_tag->Tag_CapturePaletteSetting == 0)
{
current_tag->Tag_CapturePaletteSetting = 1;
}
break;
}
case 18: //"Cropped"
{
if (!(current_tag->Tag_Cropped.length() > 0))
{
current_tag->Tag_Cropped = L"Blank";
}
break;
}
case 19: //"Disc Track"
{
if (current_tag->Tag_DiscTrack == 0)
{
current_tag->Tag_DiscTrack = 1;
}
break;
}
case 20: //"Encoder"
{
if (!(current_tag->Tag_Encoder.length() > 0))
{
current_tag->Tag_Encoder = L"Blank";
}
break;
}
case 21: //"Encode Settings"
{
if (!(current_tag->Tag_EncodeSettings.length() > 0))
{
current_tag->Tag_EncodeSettings = L"Blank";
}
break;
}
case 22: //"File"
{
if (!(current_tag->Tag_File.length() > 0))
{
current_tag->Tag_File = L"Blank";
}
break;
}
case 23: //"Initial Key"
{
if (!(current_tag->Tag_InitialKey.length() > 0))
{
current_tag->Tag_InitialKey = "Blank";
}
break;
}
case 24: //"Keywords"
{
if (!(current_tag->Tag_Keywords.length() > 0))
{
current_tag->Tag_Keywords = L"Blank";
}
break;
}
case 25: //"Language"
{
if (!(current_tag->Tag_Language.length() > 0))
{
current_tag->Tag_Language = "Blank"; //Default Language
}
break;
}
case 26: //"Length"
{
if (current_tag->Tag_Length == 0)
{
current_tag->Tag_Length = 1;
}
break;
}
case 27: //"Official Audio File URL"
{
if (!(current_tag->Tag_OfficialAudioFileURL.length() > 0))
{
current_tag->Tag_OfficialAudioFileURL = "http://";
}
break;
}
case 28: //"Official Audio Source URL"
{
if (!(current_tag->Tag_OfficialAudioSourceURL.length() > 0))
{
current_tag->Tag_OfficialAudioSourceURL = "http://";
}
break;
}
case 29: //"Original Dimensions"
{
if (!(current_tag->Tag_OriginalDimensions.length() > 0))
{
current_tag->Tag_OriginalDimensions = "Blank";
}
break;
}
case 30: //"Original Media Type"
{
if (!(current_tag->Tag_OriginalMediaType.length() > 0))
{
current_tag->Tag_OriginalMediaType = L"Blank";
}
break;
}
case 31: //"Play Counter"
{
if (current_tag->Tag_PlayCounter == 0)
{
current_tag->Tag_PlayCounter = 1;
}
break;
}
case 32: //"Playlist Delay"
{
if (current_tag->Tag_PlaylistDelay == 0)
{
current_tag->Tag_PlaylistDelay = 1;
}
break;
}
case 33: //"Popularimeter"
{
if (current_tag->Tag_Popularimeter == 0)
{
current_tag->Tag_Popularimeter = 1;
}
break;
}
case 34: //"Product"
{
if (!(current_tag->Tag_Product.length() > 0))
{
current_tag->Tag_Product = L"Blank";
}
break;
}
case 35: //"Record Location"
{
if (!(current_tag->Tag_RecordLocation.length() > 0))
{
current_tag->Tag_RecordLocation = "Blank";
}
break;
}
case 36: //"Set Part"
{
if (current_tag->Tag_SetPart == 0)
{
current_tag->Tag_SetPart = 1;
}
break;
}
case 37: //"Source"
{
if (!(current_tag->Tag_Source.length() > 0))
{
current_tag->Tag_Source = L"Blank";
}
break;
}
case 38: //"Source Form"
{
if (!(current_tag->Tag_SourceForm.length() > 0))
{
current_tag->Tag_SourceForm = L"Blank";
}
break;
}
case 39: //"Sub Genre"
{
if (!(current_tag->Tag_SubGenre.length() > 0))
{
current_tag->Tag_SubGenre = "Blank";
}
break;
}
case 40: //"Subject"
{
if (!(current_tag->Tag_Subject.length() > 0))
{
current_tag->Tag_Subject = L"Blank";
}
break;
}
case 41: //"Synchronised Tempo"
{
if (!(current_tag->Tag_SynchronisedTempo.length() > 0))
{
current_tag->Tag_SynchronisedTempo = "Blank";
}
break;
}
case 42: //"Synchronised Text"
{
if (!(current_tag->Tag_SynchronisedText.length() > 0))
{
current_tag->Tag_SynchronisedText = L"Blank";
}
break;
}
/*case 43: //"Unsynchronised Text"
{
if (!(current_tag->Tag_UnsynchronisedText.length() > 0))
{
current_tag->Tag_UnsynchronisedText = L"Blank";
}
break;
}
case 44: //"User Defined URL"
{
if (!(current_tag->Tag_UserDefinedURL.length() > 0))
{
current_tag->Tag_UserDefinedURL = "http://";
}
break;
}*/
}
}
MediaPropProc_Tag_TagEntryChange(pageData->g_hTagDialog);
EndDialog(hwndDlg, IDOK);
break;
}
case IDC_BUTTON_ADDTAG_CANCEL:
{
//User pressed cancel, so we exit this dialog
EndDialog(hwndDlg, wParam);
return TRUE;
break;
}
case IDC_LIST_ADDTAG:
{
switch (HIWORD(wParam))
{
case LBN_SELCHANGE:
{
//Let's display some infomation about the selected tag to add
int nItem = 0;
//Get the selected tag type
nItem = SendDlgItemMessage(hwndDlg, IDC_LIST_ADDTAG, LB_GETCURSEL, 0, 0);
char *field_txt = new char[SendDlgItemMessageA(hwndDlg, IDC_LIST_ADDTAG, LB_GETTEXTLEN, nItem, 0)+1];
SendDlgItemMessageA(hwndDlg, IDC_LIST_ADDTAG, LB_GETTEXT, (nItem), (LPARAM)field_txt);
uint32 tag_type = 0;
tag_type = MatroskaTagInfo::GetTagListUInt(field_txt);
//Now display the infomation about the tag,
SetDlgItemTextA(hwndDlg, IDC_STATIC_TAGADD_INFO, MatroskaTagInfo::GetTagListStrInfo(tag_type));
delete field_txt;
break;
} //case LBN_SELCHANGE:
}
}
}
} //case WM_COMMAND:
}
CRASH_PROTECT_END;
return FALSE;
};
BOOL CALLBACK MediaPropProc_AddSimpleTag(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
CRASH_PROTECT_START;
static HWND hwndToolTip = NULL;
//Get the dialog data
MatroskaPages *pageData = (MatroskaPages *)GetWindowLong(hwndDlg, DWL_USER);
switch(uMsg) {
case WM_INITDIALOG:
{
//Store the MatroskaPages struct in the DWL_USER
SetWindowLong(hwndDlg, DWL_USER, (LONG)lParam);
pageData = (MatroskaPages *)lParam;
// Create the tooltip control
DWORD balloonTips = 0;
if (MatroskaShellExt_GetRegistryValue(_T("Use Balloon Tooltips"), 1))
balloonTips = TTS_BALLOON;
hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | balloonTips,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hwndDlg, NULL, GetModuleHandle(_T("MatroskaProp")), NULL);
// Have it cover the whole window
SetWindowPos(hwndToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
// Set our own delays
SendMessage(hwndToolTip, TTM_SETDELAYTIME, (WPARAM)(DWORD)TTDT_INITIAL, (LPARAM)50);
SendMessage(hwndToolTip, TTM_SETDELAYTIME, (WPARAM)(DWORD)TTDT_AUTOPOP, (LPARAM)30*1000);
SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0, (LPARAM)160);
AddTooltip(hwndToolTip, GetDlgItem(hwndDlg, IDC_COMBO_TAG_NAME), LPSTR_TEXTCALLBACK);
SetWindowText(hwndDlg, _W("Add Simple Tag"));
SetDlgItemText(hwndDlg, IDC_STATIC_NAME, _W("Name:"));
SetDlgItemText(hwndDlg, IDC_STATIC_VALUE, _W("Value:"));
SetDlgItemText(hwndDlg, IDC_BUTTON_ADD_SIMPLE_TAG_OK, _W("OK"));
SetDlgItemText(hwndDlg, IDC_BUTTON_ADD_SIMPLE_TAG_CANCEL, _W("Cancel"));
// This crashes for some reason
#if 0
int i = 0;
HWND hNameCombo = GetDlgItem(hwndDlg, IDC_COMBO_TAG_NAME);
SendMessage(hNameCombo, CB_ADDSTRING, 0, (LPARAM)_T("test"));
while (MatroskaSimpleTag::GetOfficalList(i).name != NULL)
{
TCHAR *test = MatroskaSimpleTag::GetOfficalList(i).name;
SendMessage(hNameCombo, CB_ADDSTRING, 0, (LPARAM)test);
i++;
}
#endif
break;
}
case WM_CLOSE:
{
EndDialog(hwndDlg, IDCANCEL);
break;
}
case WM_NOTIFY:
{
NMHDR *notifyHeader = (NMHDR *)lParam;
if (notifyHeader->hwndFrom == GetDlgItem(hwndDlg, IDC_COMBO_TAG_NAME))
{
switch (notifyHeader->code)
{
case TTN_GETDISPINFO:
{
LPNMTTDISPINFO notifyHeaderData = (LPNMTTDISPINFO)notifyHeader;
int nItem = 0;
nItem = SendDlgItemMessage(hwndDlg, IDC_COMBO_TAG_NAME, CB_GETCURSEL, 0, 0);
TCHAR field_txt[1025];
GetDlgItemText(hwndDlg, IDC_COMBO_TAG_NAME, field_txt, 1024);
int i = 0;
while (MatroskaSimpleTag::GetOfficalList(i).name != NULL)
{
if (!_tcscmp(MatroskaSimpleTag::GetOfficalList(i).name, field_txt)) {
notifyHeaderData->lpszText = MatroskaSimpleTag::GetOfficalList(i).desc;
break;
}
i++;
}
break;
}
}
}
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{ // Find which control the message applies to
case IDC_BUTTON_ADD_SIMPLE_TAG_OK:
{
//Add the new simple tag :P
int nItem = 0;
int name_txt_len = SendDlgItemMessage(hwndDlg, IDC_COMBO_TAG_NAME, WM_GETTEXTLENGTH, 0, 0);
TCHAR *name_txt = new TCHAR[name_txt_len+1];
SendDlgItemMessage(hwndDlg, IDC_COMBO_TAG_NAME, WM_GETTEXT, name_txt_len+1, (LPARAM)name_txt);
int value_txt_len = SendDlgItemMessage(hwndDlg, IDC_EDIT_TAG_VALUE, WM_GETTEXTLENGTH, 0, 0);
TCHAR *value_txt = new TCHAR[value_txt_len+1];
SendDlgItemMessage(hwndDlg, IDC_EDIT_TAG_VALUE, WM_GETTEXT, value_txt_len+1, (LPARAM)value_txt);
//First find which tag is selected
MatroskaTagInfo *current_tag = GetSelectedTagEntry(pageData->g_hTagDialog);
if (current_tag != NULL) {
// Lets add the tag now
current_tag->Tag_Simple_Tags.SetSimpleTagValue(name_txt, value_txt);
}
delete name_txt;
delete value_txt;
MediaPropProc_Tag_TagEntryChange(pageData->g_hTagDialog);
EndDialog(hwndDlg, IDOK);
break;
}
case IDC_BUTTON_ADD_SIMPLE_TAG_CANCEL:
{
//User pressed cancel, so we exit this dialog
EndDialog(hwndDlg, wParam);
return TRUE;
break;
}
case IDC_COMBO_TAG_NAME:
{
switch (HIWORD(wParam))
{
case CBN_SELCHANGE:
{
/*
//Let's display some infomation about the selected tag to add
int nItem = 0;
//Get the selected tag type
nItem = SendDlgItemMessage(hwndDlg, IDC_COMBO_TAG_NAME, CB_GETCURSEL, 0, 0);
char field_txt[1025];
GetDlgItemTextA(hwndDlg, IDC_COMBO_TAG_NAME, field_txt, 1024);
int i = 0;
while (MatroskaSimpleTagOfficalList[i].name != NULL)
{
if (!strcmp(field_txt, MatroskaSimpleTagOfficalList[i].name)) {
}
i++;
}
*/
break;
} //case LBN_SELCHANGE:
}
}
}
} //case WM_COMMAND:
}
CRASH_PROTECT_END;
return FALSE;
};
BOOL CALLBACK MediaPropProc_AddUID(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
CRASH_PROTECT_START;
//Get the dialog data
MatroskaPages *pageData = (MatroskaPages *)GetWindowLong(hwndDlg, DWL_USER);
switch(uMsg) {
case WM_INITDIALOG:
{
//Store the MatroskaPages struct in the DWL_USER
SetWindowLong(hwndDlg, DWL_USER, (LONG)lParam);
pageData = (MatroskaPages *)lParam;
SetWindowText(hwndDlg, _W("Add UID"));
SetDlgItemText(hwndDlg, IDC_STATIC_ADD_UID_1, _W("Select or type in the UID to add:"));
SetDlgItemText(hwndDlg, IDC_BUTTON_ADD_UID_OK, _W("OK"));
SetDlgItemText(hwndDlg, IDC_BUTTON_ADD_UID_CANCEL, _W("Cancel"));
size_t i;
for (i = 0; i < pageData->parser->chapters.size(); i++) {
if (pageData->parser->chapters.at(i)->chapterUID != 0) {
SmartStringFormat wBuf;
wBuf << _W("Chapter");
wBuf << L": ";
wBuf << pageData->parser->chapters.at(i)->chapterUID;
SendDlgItemMessage(hwndDlg, IDC_LIST_ADD_UID, LB_ADDSTRING, 0, (LPARAM)wBuf.str().c_str());
}
}
for (i = 0; i < pageData->parser->trackInfos.size(); i++) {
if (pageData->parser->trackInfos.at(i)->m_trackUID != 0) {
SmartStringFormat wBuf;
wBuf << _W("Track");
wBuf << L": ";
wBuf << pageData->parser->trackInfos.at(i)->m_trackUID;
SendDlgItemMessage(hwndDlg, IDC_LIST_ADD_UID, LB_ADDSTRING, 0, (LPARAM)wBuf.str().c_str());
}
}
for (i = 0; i < pageData->parser->fileAttachments.size(); i++) {
if (pageData->parser->fileAttachments.at(i)->attachmentUID != 0) {
SmartStringFormat wBuf;
wBuf << _W("Attachment");
wBuf << L": ";
wBuf << pageData->parser->fileAttachments.at(i)->attachmentUID;
SendDlgItemMessage(hwndDlg, IDC_LIST_ADD_UID, LB_ADDSTRING, 0, (LPARAM)wBuf.str().c_str());
}
}
break;
}
case WM_CLOSE:
{
EndDialog(hwndDlg, IDCANCEL);
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{ // Find which control the message applies to
case IDC_BUTTON_ADD_UID_OK:
{
UTFstring selectedUID = GetSelectedListItem(hwndDlg, IDC_LIST_ADD_UID);
if (selectedUID.length() > 0) {
MatroskaTagInfo *selected_tag = GetSelectedTagEntry(pageData->g_hTagDialog);
if (selected_tag != NULL)
{
if (!_tcsncmp(selectedUID.c_str(), _W("Track"), _tcslen(_W("Track")))) {
const char *uidStart = selectedUID.GetUTF8().c_str()+strlen(_("Track"))+2;
selected_tag->Tag_TrackUID.Add(atoi64(uidStart));
} else if (!_tcsncmp(selectedUID.c_str(), _W("Chapter"), _tcslen(_W("Chapter")))) {
const char *uidStart = selectedUID.GetUTF8().c_str()+strlen(_("Chapter"))+2;
selected_tag->Tag_ChapterUID.Add(atoi64(uidStart));
} else if (!_tcsncmp(selectedUID.c_str(), _W("Attachment"), _tcslen(_W("Attachment")))) {
const char *uidStart = selectedUID.GetUTF8().c_str()+strlen(_("Attachment"))+2;
selected_tag->Tag_AttachmentUID.Add(atoi64(uidStart));
}
DisplayTagUIDList(pageData->g_hTagDialog, selected_tag);
}
} else {
MessageBox(hwndDlg, _W("No UID Selected"), NULL, 0);
break;
}
EndDialog(hwndDlg, IDOK);
break;
}
case IDC_BUTTON_ADD_UID_CANCEL:
{
//User pressed cancel, so we exit this dialog
EndDialog(hwndDlg, wParam);
return TRUE;
break;
}
case IDC_LIST_ADD_UID:
{
switch (HIWORD(wParam))
{
case LBN_SELCHANGE:
{
break;
} //case LBN_SELCHANGE:
case LBN_DBLCLK:
{
MediaPropProc_AddUID(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_ADD_UID_OK, BN_CLICKED), 0);
break;
}
}
}
}
} //case WM_COMMAND:
}
CRASH_PROTECT_END;
return FALSE;
};
BOOL CALLBACK MediaPropProc_Tag(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
//TRACE("Tag Tab Msg: %X wParam: %i lParam: %i \n", uMsg, wParam, lParam);
CRASH_PROTECT_START;
//Get the dialog data
MatroskaPages *pageData = (MatroskaPages *)GetWindowLong(hwndDlg, DWL_USER);
switch(uMsg) {
case WM_INITDIALOG:
{
ODS("Displaying Tag Tab");
INITCOMMONCONTROLSEX common;
common.dwICC = ICC_DATE_CLASSES;
common.dwSize = sizeof(common);
InitCommonControlsEx(&common);
//Store the MatroskaPages struct in the DWL_USER
SetWindowLong(hwndDlg, DWL_USER, (LONG)lParam);
pageData = (MatroskaPages *)lParam;
#ifdef MATROSKA_PROP
MoreData *pm;
// When the shell creates a dialog box for a property sheet page,
// it passes the pointer to the PROPSHEETPAGE data structure as
// lParam. The dialog procedures of extensions typically store it
// in the DWL_USER of the dialog box window.
SetWindowLong(hwndDlg, DWL_USER, lParam);
pm = (MoreData *)lParam;
pageData = pm->pObjPageData;
pageData->AddRef();
//Store the Matroska Infomation dialog handle
pageData->g_hTagDialog = hwndDlg;
//Store the MatroskaPages struct in the DWL_USER
SetWindowLong(hwndDlg, DWL_USER, (LONG)pageData);
if ((pageData->parser == NULL) || !pageData->parser->found_tags)
{
delete pageData->parser;
pageData->parser = new MatroskaInfoParser(pm->pObjPageData->szFile);
pageData->parser->m_parseSeekHead = true;
pageData->parser->m_parseAttachments = true;
pageData->parser->m_parseTags = true;
ParseFileMT(pageData, hwndDlg);
//pageData->parser->ParseFile();
}
/*DisplayTagEntryList(pageData->g_hTagDialog, pageData->parser);
// Update the tabs
if (pageData->g_hInfoDialog != NULL)
DisplayMainTrackList(pageData->g_hInfoDialog, pageData->parser);
if (pageData->g_hSimpleTagDialog != NULL)
DisplaySimpleTagTrackList(pageData->g_hSimpleTagDialog, pageData->parser);
if (pageData->g_hAttachmentDialog != NULL)
DisplayAttachmentList(pageData->g_hAttachmentDialog, pageData->parser);
*/
#endif
SetDlgItemText(hwndDlg, IDC_STATIC_TAG_FRAME_BORDER, _W("The Matroska Tagger"));
//SetDlgItemText(hwndDlg, IDC_STATIC_TAG_1, _W("Track"));
//SetDlgItemText(hwndDlg, IDC_STATIC_TRACK_UID, _W("Track UID"));
SetDlgItemText(hwndDlg, IDC_STATIC_TAG_ENTRIES, _W("Tag Entries:"));
SetDlgItemText(hwndDlg, IDC_STATIC_TAG_ASSIGNED_UID, _W("Assigned UIDs:"));
SetDlgItemText(hwndDlg, IDC_STATIC_TAG_2, _W("Tag Type:"));
SetDlgItemText(hwndDlg, IDC_STATIC_TAG_3, _W("Tag Field:"));
SetDlgItemText(hwndDlg, IDC_STATIC_TAG_4, _W("Field Text:"));
SetDlgItemText(hwndDlg, IDC_STATIC_TAG_5, _W("Tag Entry Tags"));
SetDlgItemText(hwndDlg, IDC_BUTTON_TAG_ENTRY_ADD, _W("Add"));
SetDlgItemText(hwndDlg, IDC_BUTTON_TAG_ENTRY_DELETE, _W("Delete"));
SetDlgItemText(hwndDlg, IDC_BUTTON_TAG_UID_ADD, _W("Add"));
SetDlgItemText(hwndDlg, IDC_BUTTON_TAG_UID_DELETE, _W("Delete"));
SetDlgItemText(hwndDlg, IDC_BUTTON_ADDTAG, _W("Add"));
SetDlgItemText(hwndDlg, IDC_BUTTON_DELETETAG, _W("Delete"));
SetDlgItemText(hwndDlg, IDC_BUTTON_EXPORT_XML, _W("Export as XML"));
SetDlgItemText(hwndDlg, IDC_BUTTON_TAG_IMPORT, _W("Import"));
SetDlgItemText(hwndDlg, IDC_BUTTON_TAGS_RELOAD, _W("Reload"));
SetDlgItemText(hwndDlg, IDC_BUTTON_SAVE, _W("Save"));
#ifdef MATROSKA_PROP
if (!MatroskaShellExt_GetRegistryValue(_T("Auto-Reload Tags after Save"), 1))
ShowWindow(GetDlgItem(hwndDlg, IDC_BUTTON_TAGS_RELOAD), SW_HIDE);
#else
if (!MatroskaCDL_GetRegistryValue(_T("Auto-Reload Tags after Save"), 1))
ShowWindow(GetDlgItem(hwndDlg, IDC_BUTTON_TAGS_RELOAD), SW_HIDE);
#endif
#ifndef USING_TINYXML
ShowWindow(GetDlgItem(hwndDlg, IDC_BUTTON_EXPORT_XML), SW_HIDE);
#endif
break;
}
case WM_DESTROY:
{
#ifdef MATROSKA_PROP
pageData->Release();
#endif // MATROSKA_PROP
break;
}
case WM_NOTIFY:
{
NMHDR *notifyHeader = (NMHDR *)lParam;
if ((notifyHeader->hwndFrom == GetDlgItem(hwndDlg, IDC_TAG_DATETIMEPICKER_DATE))
|| (notifyHeader->hwndFrom == GetDlgItem(hwndDlg, IDC_TAG_DATETIMEPICKER_TIME)))
{
LPNMDATETIMECHANGE notifyHeaderData = (LPNMDATETIMECHANGE)notifyHeader;
switch (notifyHeaderData->nmhdr.code)
{
case DTN_DATETIMECHANGE:
{
HWND hwndTagFieldCombo = GetDlgItem(hwndDlg, IDC_COMBO_TAG_FIELD);
LRESULT nItem = SendMessage(hwndTagFieldCombo, CB_GETCURSEL, 0, 0); ;
if (nItem != CB_ERR)
{
int64 *date_field = reinterpret_cast<int64 *>(SendMessage(hwndTagFieldCombo, CB_GETITEMDATA, (nItem), 0));
if (date_field != NULL) {
SYSTEMTIME theTime;
tm new_date;
DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TAG_DATETIMEPICKER_TIME), &theTime);
new_date.tm_hour = theTime.wHour;
new_date.tm_min = theTime.wMinute;
new_date.tm_sec = theTime.wSecond;
DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TAG_DATETIMEPICKER_DATE), &theTime);
new_date.tm_mon = theTime.wMonth-1;
new_date.tm_mday = theTime.wDay;
new_date.tm_year = theTime.wYear-1900;
new_date.tm_isdst = -1;
*date_field = _mktime64(&new_date);
}
}
break;
};
}
}
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam)) { /* Find which control the message applies to */
case IDC_BUTTON_SAVE:
{
ODS("MediaPropProc_Tag::Matroska Tag Save button pressed.");